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

View File

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

View File

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