mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:21:32 +00:00
Refactor EventHandles supervisord access to a mixin
This commit is contained in:
parent
3a7349abd4
commit
2b306efb04
@ -1,4 +1,6 @@
|
|||||||
import json
|
import json, xmlrpc.client
|
||||||
|
|
||||||
|
from config.envvars import SUPERVISOR_HTTP_URI
|
||||||
|
|
||||||
|
|
||||||
def parse_anchor_from_message(message):
|
def parse_anchor_from_message(message):
|
||||||
@ -12,3 +14,6 @@ def create_source_code_response_data(filename, content, language):
|
|||||||
'content': content,
|
'content': content,
|
||||||
'language': language
|
'language': language
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SupervisorMixin:
|
||||||
|
supervisor = xmlrpc.client.ServerProxy(SUPERVISOR_HTTP_URI).supervisor
|
@ -1,13 +1,12 @@
|
|||||||
import json
|
|
||||||
from shutil import copy, rmtree, copytree
|
from shutil import copy, rmtree, copytree
|
||||||
from os.path import splitext
|
from os.path import splitext
|
||||||
import xmlrpc.client
|
|
||||||
|
|
||||||
from config import SUPERVISOR_HTTP_URI, LOGIN_APP_DIR
|
from util import SupervisorMixin
|
||||||
|
from config import LOGIN_APP_DIR
|
||||||
from event_handler_base import EventHandlerBase
|
from event_handler_base import EventHandlerBase
|
||||||
|
|
||||||
|
|
||||||
class SourceCodeEventHandler(EventHandlerBase):
|
class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
||||||
def __init__(self, anchor, filename, process_name=None, zmq_context=None):
|
def __init__(self, anchor, filename, process_name=None, zmq_context=None):
|
||||||
super().__init__(anchor, zmq_context)
|
super().__init__(anchor, zmq_context)
|
||||||
self.working_directory = LOGIN_APP_DIR
|
self.working_directory = LOGIN_APP_DIR
|
||||||
@ -19,9 +18,6 @@ class SourceCodeEventHandler(EventHandlerBase):
|
|||||||
'write': self.write_file
|
'write': self.write_file
|
||||||
}
|
}
|
||||||
|
|
||||||
server = xmlrpc.client.ServerProxy(SUPERVISOR_HTTP_URI)
|
|
||||||
self.supervisor = server.supervisor
|
|
||||||
|
|
||||||
self.file = self.create_initial_state()
|
self.file = self.create_initial_state()
|
||||||
|
|
||||||
def handle_event(self, anchor, data_json):
|
def handle_event(self, anchor, data_json):
|
||||||
|
Loading…
Reference in New Issue
Block a user