Implement DirManagingEH selectdir API

This commit is contained in:
Kristóf Tóth 2018-03-15 21:05:16 +01:00
parent 7b834f8f25
commit 222143665c

View File

@ -75,9 +75,10 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
self._directory = directory
self._monitor = None
self.reload_monitor()
self.commands = {'pause': self.pause,
'resume': self.resume,
'ignore': self.ignore}
self.commands = {'pause': self.pause,
'resume': self.resume,
'ignore': self.ignore,
'selectdir': self.selectdir}
@property
def directory(self):
@ -118,5 +119,13 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
self.monitor.ignore += data['ignore']
return data
def selectdir(self, data):
try:
self.directory = data['directory']
self.reload_monitor()
return data
except EnvironmentError:
log.error('DirManagingEH failed to switch directory!')
def cleanup(self):
self.monitor.stop()