mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:31:33 +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)
|
super().__init__(key)
|
||||||
self.filemanager = FileManager(directory, selected_file=selected_file, exclude=exclude)
|
self.filemanager = FileManager(directory, selected_file=selected_file, exclude=exclude)
|
||||||
|
|
||||||
self.commands = {
|
self.commands = {'read': self.read,
|
||||||
'read': self.read,
|
'write': self.write,
|
||||||
'write': self.write,
|
'select': self.select,
|
||||||
'select': self.select
|
'selectdir': self.select_dir}
|
||||||
}
|
|
||||||
|
|
||||||
self._monitor = DirectoryMonitor(directory)
|
self._monitor = DirectoryMonitor(directory)
|
||||||
self._monitor.watch() # This runs on a separate thread
|
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']))
|
except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename']))
|
||||||
return data
|
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):
|
def attach_fileinfo(self, data):
|
||||||
data['filename'] = self.filemanager.filename
|
data['filename'] = self.filemanager.filename
|
||||||
data['files'] = self.filemanager.files
|
data['files'] = self.filemanager.files
|
||||||
|
Loading…
Reference in New Issue
Block a user