mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:31:31 +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.filename = filename
|
||||||
self.language = map_file_extension_to_language(filename)
|
self.language = map_file_extension_to_language(filename)
|
||||||
self.process_name = process_name or splitext(filename)[0]
|
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)
|
server = xmlrpc.client.ServerProxy(SUPERVISOR_HTTP_URI)
|
||||||
self.supervisor = server.supervisor
|
self.supervisor = server.supervisor
|
||||||
@ -22,9 +26,7 @@ class SourceCodeEventHandler(EventHandlerBase):
|
|||||||
|
|
||||||
def handle_event(self, anchor, data_json):
|
def handle_event(self, anchor, data_json):
|
||||||
data = data_json['data']
|
data = data_json['data']
|
||||||
command_handlers = {'read': self.read_file,
|
self.commands[data['command']](data_json)
|
||||||
'write': self.write_file}
|
|
||||||
command_handlers[data['command']](data_json)
|
|
||||||
return data_json
|
return data_json
|
||||||
|
|
||||||
def handle_reset(self, data_json):
|
def handle_reset(self, data_json):
|
||||||
|
Loading…
Reference in New Issue
Block a user