mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:51:31 +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
|
return wrapper
|
||||||
|
|
||||||
@_with_monitor_paused
|
@_with_monitor_paused
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, message):
|
||||||
try:
|
try:
|
||||||
data = data_json['data']
|
data = message['data']
|
||||||
self.processmanager(data['command'], data['process_name'])
|
self.processmanager(data['command'], data['process_name'])
|
||||||
return data_json
|
return message
|
||||||
except KeyError:
|
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:
|
except SupervisorFault as fault:
|
||||||
data_json['data']['error'] = fault.faultString
|
message['data']['error'] = fault.faultString
|
||||||
data_json['data']['log'] = self.processmanager.read_log(data_json['data']['process_name'])
|
message['data']['log'] = self.processmanager.read_log(message['data']['process_name'])
|
||||||
log.debug('Failed to execute command on process: {}'.format(data_json))
|
log.debug('Failed to execute command on process: {}'.format(message))
|
||||||
return data_json
|
return message
|
||||||
|
@ -83,14 +83,14 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
|||||||
data['filename'] = self.filemanager.filename
|
data['filename'] = self.filemanager.filename
|
||||||
data['files'] = self.filemanager.files
|
data['files'] = self.filemanager.files
|
||||||
|
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, message):
|
||||||
try:
|
try:
|
||||||
data = data_json['data']
|
data = message['data']
|
||||||
data_json['data'] = self.commands[data['command']](data)
|
message['data'] = self.commands[data['command']](data)
|
||||||
self.attach_fileinfo(data)
|
self.attach_fileinfo(data)
|
||||||
return data_json
|
return message
|
||||||
except KeyError:
|
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):
|
def cleanup(self):
|
||||||
self.monitor.stop()
|
self.monitor.stop()
|
||||||
|
@ -21,13 +21,13 @@ class TerminadoEventHandler(TriggerlessEventHandler):
|
|||||||
def historymonitor(self):
|
def historymonitor(self):
|
||||||
return self._historymonitor
|
return self._historymonitor
|
||||||
|
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, message):
|
||||||
log.debug('TerminadoEventHandler received event: {}'.format(data_json))
|
log.debug('TerminadoEventHandler received event: {}'.format(message))
|
||||||
try:
|
try:
|
||||||
data_json['data'] = self.commands[data_json['data']['command']](data_json['data'])
|
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||||
return data_json
|
return message
|
||||||
except KeyError:
|
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):
|
def write(self, data):
|
||||||
self.terminado_server.pty.write(data['shellcmd'])
|
self.terminado_server.pty.write(data['shellcmd'])
|
||||||
|
@ -39,10 +39,10 @@ class EventHandlerBase:
|
|||||||
if key != 'reset': return self.handle_event(key, message)
|
if key != 'reset': return self.handle_event(key, message)
|
||||||
else: return self.handle_reset(message)
|
else: return self.handle_reset(message)
|
||||||
|
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, message):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def handle_reset(self, data_json):
|
def handle_reset(self, message):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user