mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 04:51:55 +00:00
Implement error handling in SourceCodeEventHandler.select_dir()
This commit is contained in:
parent
20895cb989
commit
3b241a3930
@ -90,8 +90,15 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
return data
|
||||
|
||||
def select_dir(self, data):
|
||||
try: self.filemanager.workdir = data['directory']
|
||||
except EnvironmentError: log.exception('Failed to select directory "{}"'.format(data['directory']))
|
||||
try:
|
||||
self.filemanager.workdir = data['directory']
|
||||
try:
|
||||
self.filemanager.select_file(self.filemanager.files[0])
|
||||
data['content'] = self.filemanager.file_contents
|
||||
except IndexError:
|
||||
data['content'] = 'No files in this directory :('
|
||||
except EnvironmentError:
|
||||
log.exception('Failed to select directory "{}"'.format(data['directory']))
|
||||
return data
|
||||
|
||||
def attach_fileinfo(self, data):
|
||||
|
Loading…
Reference in New Issue
Block a user