mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 23:41:22 +00:00
Fix IdeEventHandler not working with arbitrary keys
This commit is contained in:
parent
20f8cdb00c
commit
83dd6ae836
@ -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'}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user