-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (25 loc) · 882 Bytes
/
main.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
import logging
import threading
import signal
from smartfridge import SmartFridge
from configuration import configuration
class Main:
def __init__(self):
signal.signal(signal.SIGTERM, self.__stop)
signal.signal(signal.SIGINT, self.__stop)
self.__event = threading.Event()
self.__init_logging()
self.__smart_fridge = SmartFridge(self.__event.is_set)
def run(self):
self.__smart_fridge.start()
self.__smart_fridge.stop()
logging.info("Process terminated")
def __init_logging(self):
logging.basicConfig(format = '%(asctime)s %(levelname)s %(message)s', level = logging.INFO)
logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR)
logging.info(f"Using configuration: {configuration}")
def __stop(self, signal_number, _):
signal.signal(signal_number, signal.SIG_IGN)
self.__event.set()
if __name__ == "__main__":
Main().run()