mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 14:41:20 +00:00
Make SourceCodeEventHandler command handlers data_json['data'] based
This commit is contained in:
parent
6283b825d6
commit
792981742c
@ -65,28 +65,27 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||
copy('source_code_server/server.py', LOGIN_APP_DIR)
|
||||
copy('source_code_server/users.db', LOGIN_APP_DIR)
|
||||
|
||||
def read(self, data_json):
|
||||
data_json['data'] = {
|
||||
'filename': self.filemanager.filename,
|
||||
'content': self.filemanager.file_contents,
|
||||
'language': self.filemanager.language,
|
||||
'files': self.filemanager.files
|
||||
}
|
||||
def read(self, data):
|
||||
data['filename'] = self.filemanager.filename
|
||||
data['content'] = self.filemanager.file_contents
|
||||
data['language'] = self.filemanager.language
|
||||
data['files'] = self.filemanager.files
|
||||
return data
|
||||
|
||||
def write(self, data_json):
|
||||
self.filemanager.file_contents = data_json['data']['content']
|
||||
data_json['data']['files'] = self.filemanager.files
|
||||
def write(self, data):
|
||||
self.filemanager.file_contents = data['content']
|
||||
data['files'] = self.filemanager.files
|
||||
self.restart_process()
|
||||
return data
|
||||
|
||||
def select(self, data_json):
|
||||
try:
|
||||
self.filemanager.select_file(data_json['data']['filename'])
|
||||
except EnvironmentError:
|
||||
log.critical('Failed to select file "{}"'.format(data_json['data']['filename']))
|
||||
def select(self, data):
|
||||
try: self.filemanager.select_file(data['filename'])
|
||||
except EnvironmentError: log.critical('Failed to select file "{}"'.format(data['filename']))
|
||||
return data
|
||||
|
||||
def handle_event(self, anchor, data_json):
|
||||
data = data_json['data']
|
||||
self.commands[data['command']](data_json)
|
||||
data_json['data'] = self.commands[data['command']](data)
|
||||
return data_json
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user