mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 22:41:33 +00:00
Root out remaining ambiguous key arguments in EventHandlers
This commit is contained in:
parent
0cd11f9d64
commit
ecec1cde59
@ -44,7 +44,7 @@ class DirectoryMonitoringEventHandler(TriggerlessEventHandler):
|
|||||||
self._monitor = DirectoryMonitor(self._directory)
|
self._monitor = DirectoryMonitor(self._directory)
|
||||||
self._monitor.watch() # This runs on a separate thread
|
self._monitor.watch() # This runs on a separate thread
|
||||||
|
|
||||||
def handle_event(self, key, message):
|
def handle_event(self, message):
|
||||||
try:
|
try:
|
||||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||||
return message
|
return message
|
||||||
|
@ -30,7 +30,7 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
|||||||
self.processmanager = ProcessManager()
|
self.processmanager = ProcessManager()
|
||||||
|
|
||||||
@with_monitor_paused
|
@with_monitor_paused
|
||||||
def handle_event(self, key, message):
|
def handle_event(self, message):
|
||||||
try:
|
try:
|
||||||
data = message['data']
|
data = message['data']
|
||||||
self.processmanager(data['command'], data['process_name'])
|
self.processmanager(data['command'], data['process_name'])
|
||||||
|
@ -27,7 +27,7 @@ class TerminadoEventHandler(TriggerlessEventHandler):
|
|||||||
def historymonitor(self):
|
def historymonitor(self):
|
||||||
return self._historymonitor
|
return self._historymonitor
|
||||||
|
|
||||||
def handle_event(self, key, message):
|
def handle_event(self, message):
|
||||||
LOG.debug('TerminadoEventHandler received event: %s', message)
|
LOG.debug('TerminadoEventHandler received event: %s', message)
|
||||||
try:
|
try:
|
||||||
message['data'] = self.commands[message['data']['command']](message['data'])
|
message['data'] = self.commands[message['data']['command']](message['data'])
|
||||||
|
@ -171,7 +171,7 @@ class WebideEventHandler(TriggerlessEventHandler):
|
|||||||
data['files'] = self.filemanager.files
|
data['files'] = self.filemanager.files
|
||||||
data['directory'] = self.filemanager.workdir
|
data['directory'] = self.filemanager.workdir
|
||||||
|
|
||||||
def handle_event(self, key, message):
|
def handle_event(self, message):
|
||||||
try:
|
try:
|
||||||
data = message['data']
|
data = message['data']
|
||||||
message['data'] = self.commands[data['command']](data)
|
message['data'] = self.commands[data['command']](data)
|
||||||
|
@ -19,25 +19,25 @@ class EventHandlerBase(ABC):
|
|||||||
def event_handler_callback(self, msg_parts):
|
def event_handler_callback(self, msg_parts):
|
||||||
message = deserialize_tfw_msg(*msg_parts)
|
message = deserialize_tfw_msg(*msg_parts)
|
||||||
key = message['key']
|
key = message['key']
|
||||||
response = self.dispatch_handling(key, message)
|
response = self.dispatch_handling(message)
|
||||||
response['key'] = key
|
response['key'] = key
|
||||||
if response is None:
|
if response is None:
|
||||||
return
|
return
|
||||||
self.server_connector.send(response)
|
self.server_connector.send(response)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def dispatch_handling(self, key, message):
|
def dispatch_handling(self, message):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _dispatch_handling(self, key, message):
|
def _dispatch_handling(self, message):
|
||||||
# pylint: disable=no-else-return
|
# pylint: disable=no-else-return
|
||||||
if key != 'reset':
|
if message['key'] != 'reset':
|
||||||
return self.handle_event(key, message)
|
return self.handle_event(message)
|
||||||
else:
|
else:
|
||||||
return self.handle_reset(message)
|
return self.handle_reset(message)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def handle_event(self, key, message):
|
def handle_event(self, message):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def handle_reset(self, message):
|
def handle_reset(self, message):
|
||||||
@ -67,8 +67,8 @@ class EventHandlerBase(ABC):
|
|||||||
|
|
||||||
class TriggerlessEventHandler(EventHandlerBase, ABC):
|
class TriggerlessEventHandler(EventHandlerBase, ABC):
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
def dispatch_handling(self, key, message):
|
def dispatch_handling(self, message):
|
||||||
return self._dispatch_handling(key, message)
|
return self._dispatch_handling(message)
|
||||||
|
|
||||||
|
|
||||||
class TriggeredEventHandler(EventHandlerBase, ABC):
|
class TriggeredEventHandler(EventHandlerBase, ABC):
|
||||||
@ -77,7 +77,7 @@ class TriggeredEventHandler(EventHandlerBase, ABC):
|
|||||||
super().__init__(key)
|
super().__init__(key)
|
||||||
self.trigger = trigger
|
self.trigger = trigger
|
||||||
|
|
||||||
def dispatch_handling(self, key, message):
|
def dispatch_handling(self, message):
|
||||||
if message.get('trigger') == self.trigger:
|
if message.get('trigger') == self.trigger:
|
||||||
return self._dispatch_handling(key, message)
|
return self._dispatch_handling(message)
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user