mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 04:51:55 +00:00
Refactor naming conventions: data_json -> message in TFW EventHandlers
This commit is contained in:
parent
36724c5c51
commit
af1a6261cc
@ -35,15 +35,15 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
||||
return wrapper
|
||||
|
||||
@_with_monitor_paused
|
||||
def handle_event(self, key, data_json):
|
||||
def handle_event(self, key, message):
|
||||
try:
|
||||
data = data_json['data']
|
||||
data = message['data']
|
||||
self.processmanager(data['command'], data['process_name'])
|
||||
return data_json
|
||||
return message
|
||||
except KeyError:
|
||||
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
|
||||
log.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
except SupervisorFault as fault:
|
||||
data_json['data']['error'] = fault.faultString
|
||||
data_json['data']['log'] = self.processmanager.read_log(data_json['data']['process_name'])
|
||||
log.debug('Failed to execute command on process: {}'.format(data_json))
|
||||
return data_json
|
||||
message['data']['error'] = fault.faultString
|
||||
message['data']['log'] = self.processmanager.read_log(message['data']['process_name'])
|
||||
log.debug('Failed to execute command on process: {}'.format(message))
|
||||
return message
|
||||
|
@ -83,14 +83,14 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
||||
data['filename'] = self.filemanager.filename
|
||||
data['files'] = self.filemanager.files
|
||||
|
||||
def handle_event(self, key, data_json):
|
||||
def handle_event(self, key, message):
|
||||
try:
|
||||
data = data_json['data']
|
||||
data_json['data'] = self.commands[data['command']](data)
|
||||
data = message['data']
|
||||
message['data'] = self.commands[data['command']](data)
|
||||
self.attach_fileinfo(data)
|
||||
return data_json
|
||||
return message
|
||||
except KeyError:
|
||||
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
|
||||
log.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
|
||||
def cleanup(self):
|
||||
self.monitor.stop()
|
||||
|
@ -21,13 +21,13 @@ class TerminadoEventHandler(TriggerlessEventHandler):
|
||||
def historymonitor(self):
|
||||
return self._historymonitor
|
||||
|
||||
def handle_event(self, key, data_json):
|
||||
log.debug('TerminadoEventHandler received event: {}'.format(data_json))
|
||||
def handle_event(self, key, message):
|
||||
log.debug('TerminadoEventHandler received event: {}'.format(message))
|
||||
try:
|
||||
data_json['data'] = self.commands[data_json['data']['command']](data_json['data'])
|
||||
return data_json
|
||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||
return message
|
||||
except KeyError:
|
||||
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
|
||||
log.error('IGNORING MESSAGE: Invalid message received: {}'.format(message))
|
||||
|
||||
def write(self, data):
|
||||
self.terminado_server.pty.write(data['shellcmd'])
|
||||
|
@ -39,10 +39,10 @@ class EventHandlerBase:
|
||||
if key != 'reset': return self.handle_event(key, message)
|
||||
else: return self.handle_reset(message)
|
||||
|
||||
def handle_event(self, key, data_json):
|
||||
def handle_event(self, key, message):
|
||||
raise NotImplementedError
|
||||
|
||||
def handle_reset(self, data_json):
|
||||
def handle_reset(self, message):
|
||||
return None
|
||||
|
||||
def cleanup(self):
|
||||
|
Loading…
Reference in New Issue
Block a user