mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 18:31:33 +00:00
Implement error handling on EventHandler exposing APIs
This commit is contained in:
parent
be6f657de1
commit
2c816d5a38
@ -36,6 +36,9 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
|||||||
|
|
||||||
@_with_monitor_paused
|
@_with_monitor_paused
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, data_json):
|
||||||
data = data_json['data']
|
try:
|
||||||
self.processmanager(data['command'], data['process_name'])
|
data = data_json['data']
|
||||||
self.uplink.send(self.key, {'data': {'process_name': data['process_name']}})
|
self.processmanager(data['command'], data['process_name'])
|
||||||
|
self.uplink.send(self.key, {'data': {'process_name': data['process_name']}})
|
||||||
|
except KeyError:
|
||||||
|
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
|
||||||
|
@ -84,10 +84,13 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
|
|||||||
data['files'] = self.filemanager.files
|
data['files'] = self.filemanager.files
|
||||||
|
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, data_json):
|
||||||
data = data_json['data']
|
try:
|
||||||
data_json['data'] = self.commands[data['command']](data)
|
data = data_json['data']
|
||||||
self.attach_fileinfo(data)
|
data_json['data'] = self.commands[data['command']](data)
|
||||||
return data_json
|
self.attach_fileinfo(data)
|
||||||
|
return data_json
|
||||||
|
except KeyError:
|
||||||
|
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self.monitor.stop()
|
self.monitor.stop()
|
||||||
|
@ -23,8 +23,11 @@ class TerminadoEventHandler(TriggerlessEventHandler):
|
|||||||
|
|
||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, data_json):
|
||||||
log.debug('TerminadoEventHandler received event: {}'.format(data_json))
|
log.debug('TerminadoEventHandler received event: {}'.format(data_json))
|
||||||
data_json['data'] = self.commands[data_json['data']['command']](data_json['data'])
|
try:
|
||||||
return data_json
|
data_json['data'] = self.commands[data_json['data']['command']](data_json['data'])
|
||||||
|
return data_json
|
||||||
|
except KeyError:
|
||||||
|
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
self.terminado_server.pty.write(data['shellcmd'])
|
self.terminado_server.pty.write(data['shellcmd'])
|
||||||
|
Loading…
Reference in New Issue
Block a user