mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 13:01:32 +00:00
Move commands to class variable
This commit is contained in:
parent
677bd57ba4
commit
ce07c4d6ec
@ -14,6 +14,10 @@ class SourceCodeEventHandler(EventHandlerBase):
|
||||
self.filename = filename
|
||||
self.language = map_file_extension_to_language(filename)
|
||||
self.process_name = process_name or splitext(filename)[0]
|
||||
self.commands = {
|
||||
'read': self.read_file,
|
||||
'write': self.write_file
|
||||
}
|
||||
|
||||
server = xmlrpc.client.ServerProxy(SUPERVISOR_HTTP_URI)
|
||||
self.supervisor = server.supervisor
|
||||
@ -22,9 +26,7 @@ class SourceCodeEventHandler(EventHandlerBase):
|
||||
|
||||
def handle_event(self, anchor, data_json):
|
||||
data = data_json['data']
|
||||
command_handlers = {'read': self.read_file,
|
||||
'write': self.write_file}
|
||||
command_handlers[data['command']](data_json)
|
||||
self.commands[data['command']](data_json)
|
||||
return data_json
|
||||
|
||||
def handle_reset(self, data_json):
|
||||
|
Loading…
Reference in New Issue
Block a user