mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:41:32 +00:00
Implement support to change working directories in SourceCodeEventHandler
This commit is contained in:
parent
7858caf51a
commit
9e4fe87d84
@ -58,11 +58,10 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
super().__init__(key)
|
||||
self.filemanager = FileManager(directory, selected_file=selected_file, exclude=exclude)
|
||||
|
||||
self.commands = {
|
||||
'read': self.read,
|
||||
self.commands = {'read': self.read,
|
||||
'write': self.write,
|
||||
'select': self.select
|
||||
}
|
||||
'select': self.select,
|
||||
'selectdir': self.select_dir}
|
||||
|
||||
self._monitor = DirectoryMonitor(directory)
|
||||
self._monitor.watch() # This runs on a separate thread
|
||||
@ -90,6 +89,11 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename']))
|
||||
return data
|
||||
|
||||
def select_dir(self, data):
|
||||
try: self.filemanager.workdir = data['directory']
|
||||
except EnvironmentError: log.exception('Failed to select directory "{}"'.format(data['directory']))
|
||||
return data
|
||||
|
||||
def attach_fileinfo(self, data):
|
||||
data['filename'] = self.filemanager.filename
|
||||
data['files'] = self.filemanager.files
|
||||
|
Loading…
Reference in New Issue
Block a user