Implement uplink notifications in ProcessManagingEventHandler

This commit is contained in:
Kristóf Tóth 2018-02-27 15:26:16 +01:00
parent b50a2e401f
commit 57bd2aec45

View File

@ -1,5 +1,6 @@
from tfw.event_handler_base import TriggerlessEventHandler from tfw.event_handler_base import TriggerlessEventHandler
from tfw.components.mixins import SupervisorMixin from tfw.components.mixins import SupervisorMixin
from tfw.networking.event_handlers.server_connector import ServerUplinkConnector
from tfw.config.logs import logging from tfw.config.logs import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -18,7 +19,10 @@ class ProcessManager(SupervisorMixin):
class ProcessManagingEventHandler(TriggerlessEventHandler): class ProcessManagingEventHandler(TriggerlessEventHandler):
def __init__(self, key, supervisor_process_name): def __init__(self, key, supervisor_process_name):
super().__init__(key) super().__init__(key)
self.key = key
self.processmanager = ProcessManager(supervisor_process_name) self.processmanager = ProcessManager(supervisor_process_name)
self.uplink = ServerUplinkConnector()
def handle_event(self, key, data_json): def handle_event(self, key, data_json):
self.processmanager(data_json['data']['command']) self.processmanager(data_json['data']['command'])
self.uplink.send(self.key, {'key': self.key})