forked from insanoid/Apple-Store-Reserve-Monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor.py
executable file
·40 lines (26 loc) · 810 Bytes
/
monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
from __future__ import print_function, unicode_literals
import os
import signal
import sys
import time
from store_checker import StoreChecker
def signal_handler(signal, frame):
print(" - Stop Monitoring")
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
class Monitor:
"""A class to constantly monitor stock at periodic intervals."""
POLLING_INTERVAL_SECONDS = 30
def __init__(self):
"""Initializer."""
print("Apple Store Monitoring \n")
self.store_checker = StoreChecker()
def start_monitoring(self):
"""Start monitoring store's stock."""
while True:
self.store_checker.refresh()
time.sleep(30)
if __name__ == "__main__":
monitor = Monitor()
monitor.start_monitoring()