-
Notifications
You must be signed in to change notification settings - Fork 2
/
marvin.py
executable file
·36 lines (31 loc) · 1.08 KB
/
marvin.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
import logging
import queue
from config import Config
from file_event import FileEvent
from file_monitor import FileMonitor
from logger import Logger
from notifications.notification_event import NotificationEvent
from notifications.notifications import Notifications
if __name__ == "__main__":
config = Config("config.json")
logger = Logger(config)
file_event_queue = queue.Queue()
file_monitor = FileMonitor(config, file_event_queue)
notifications = Notifications(config, file_event_queue)
try:
file_monitor.start()
notifications.start()
while True:
try:
event = file_event_queue.get(timeout=5)
if isinstance(event, FileEvent):
logger.log_file_event(event)
elif isinstance(event, NotificationEvent):
logger.log_notification_event(event)
except queue.Empty:
pass
except KeyboardInterrupt:
file_monitor.join()
notifications.join()
logging.shutdown()
exit()