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

@ -77,7 +77,8 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
self.reload_monitor() self.reload_monitor()
self.commands = {'pause': self.pause, self.commands = {'pause': self.pause,
'resume': self.resume, 'resume': self.resume,
'ignore': self.ignore} 'ignore': self.ignore,
'selectdir': self.selectdir}
@property @property
def directory(self): def directory(self):
@ -118,5 +119,13 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
self.monitor.ignore += data['ignore'] self.monitor.ignore += data['ignore']
return data 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): def cleanup(self):
self.monitor.stop() self.monitor.stop()