Implement sending reload command on file system changes

This commit is contained in:
Kristóf Tóth 2018-02-12 16:43:30 +01:00
parent 9c006451bf
commit 67579aea29

View File

@ -1,16 +1,22 @@
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler from watchdog.events import FileSystemEventHandler
from tfw.message_sender import MessageSender from tfw.networking.event_handlers.server_connector import ServerUplinkConnector
from tfw.config.logs import logging
log = logging.getLogger(__name__)
class MessagingEventHandler(FileSystemEventHandler): class MessagingEventHandler(FileSystemEventHandler):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.message_sender = MessageSender() self.uplink = ServerUplinkConnector()
def on_modified(self, event): def on_modified(self, event):
self.message_sender.send('Watchdog', 'CECA') log.debug(event)
anchor = 'anchor_webide'
self.uplink.send(anchor, {'anchor': anchor,
'data': {'command': 'reload'}})
class DirectoryMonitor: class DirectoryMonitor: