Fix IdeEventHandler not working with arbitrary keys

This commit is contained in:
Kristóf Tóth 2018-06-18 15:13:39 +02:00
parent 20f8cdb00c
commit 83dd6ae836
3 changed files with 12 additions and 5 deletions

View File

@ -15,8 +15,8 @@ LOG = logging.getLogger(__name__)
class DirectoryMonitor(ObserverMixin): class DirectoryMonitor(ObserverMixin):
def __init__(self, directories): def __init__(self, ide_key, directories):
self.eventhandler = IdeReloadWatchdogEventHandler() self.eventhandler = IdeReloadWatchdogEventHandler(ide_key)
for directory in directories: for directory in directories:
self.observer.schedule(self.eventhandler, directory, recursive=True) self.observer.schedule(self.eventhandler, directory, recursive=True)
@ -44,8 +44,9 @@ class DirectoryMonitor(ObserverMixin):
class IdeReloadWatchdogEventHandler(FileSystemWatchdogEventHandler): class IdeReloadWatchdogEventHandler(FileSystemWatchdogEventHandler):
def __init__(self): def __init__(self, ide_key):
super().__init__() super().__init__()
self.ide_key = ide_key
self.uplink = ServerUplinkConnector() self.uplink = ServerUplinkConnector()
self._paused = False self._paused = False
self.ignore = 0 self.ignore = 0
@ -65,7 +66,7 @@ class IdeReloadWatchdogEventHandler(FileSystemWatchdogEventHandler):
return return
LOG.debug(event) LOG.debug(event)
self.uplink.send({ self.uplink.send({
'key': 'ide', 'key': self.ide_key,
'data': {'command': 'reload'} 'data': {'command': 'reload'}
}) })

View File

@ -15,7 +15,12 @@ class DirectoryMonitoringEventHandler(EventHandlerBase, MonitorManagerMixin):
def __init__(self, key, directory): def __init__(self, key, directory):
super().__init__(key) super().__init__(key)
self._directory = directory self._directory = directory
MonitorManagerMixin.__init__(self, DirectoryMonitor, self._directory) MonitorManagerMixin.__init__(
self,
DirectoryMonitor,
key,
self._directory
)
self.commands = { self.commands = {
'pause': self.pause, 'pause': self.pause,

View File

@ -141,6 +141,7 @@ class IdeEventHandler(EventHandlerBase, MonitorManagerMixin):
MonitorManagerMixin.__init__( MonitorManagerMixin.__init__(
self, self,
DirectoryMonitor, DirectoryMonitor,
self.key,
self.filemanager.allowed_directories self.filemanager.allowed_directories
) )