diff --git a/lib/tfw/__init__.py b/lib/tfw/__init__.py index a97731f..d0e877b 100644 --- a/lib/tfw/__init__.py +++ b/lib/tfw/__init__.py @@ -1,6 +1,6 @@ # Copyright (C) 2018 Avatao.com Innovative Learning Kft. # All Rights Reserved. See LICENSE file for details. -from .event_handler_base import TriggerlessEventHandler, TriggeredEventHandler +from .event_handler_base import EventHandlerBase, TriggeredEventHandler from .fsm_base import FSMBase from .linear_fsm import LinearFSM diff --git a/lib/tfw/components/directory_monitoring_event_handler.py b/lib/tfw/components/directory_monitoring_event_handler.py index 091b76e..03f58e1 100644 --- a/lib/tfw/components/directory_monitoring_event_handler.py +++ b/lib/tfw/components/directory_monitoring_event_handler.py @@ -3,7 +3,7 @@ from os.path import isdir, exists -from tfw import TriggerlessEventHandler +from tfw import EventHandlerBase from tfw.config.logs import logging from tfw.mixins import MonitorManagerMixin from .directory_monitor import DirectoryMonitor @@ -11,7 +11,7 @@ from .directory_monitor import DirectoryMonitor LOG = logging.getLogger(__name__) -class DirectoryMonitoringEventHandler(TriggerlessEventHandler, MonitorManagerMixin): +class DirectoryMonitoringEventHandler(EventHandlerBase, MonitorManagerMixin): def __init__(self, key, directory): super().__init__(key) self._directory = directory diff --git a/lib/tfw/components/process_managing_event_handler.py b/lib/tfw/components/process_managing_event_handler.py index 3246174..8ec5c80 100644 --- a/lib/tfw/components/process_managing_event_handler.py +++ b/lib/tfw/components/process_managing_event_handler.py @@ -3,7 +3,7 @@ from xmlrpc.client import Fault as SupervisorFault -from tfw import TriggerlessEventHandler +from tfw import EventHandlerBase from tfw.mixins import SupervisorMixin from tfw.config.logs import logging from .directory_monitor import with_monitor_paused @@ -22,7 +22,7 @@ class ProcessManager(SupervisorMixin): return self.commands[command](process_name) -class ProcessManagingEventHandler(TriggerlessEventHandler): +class ProcessManagingEventHandler(EventHandlerBase): def __init__(self, key, dirmonitor=None): super().__init__(key) self.key = key diff --git a/lib/tfw/components/terminado_event_handler.py b/lib/tfw/components/terminado_event_handler.py index 06347a1..c0351c9 100644 --- a/lib/tfw/components/terminado_event_handler.py +++ b/lib/tfw/components/terminado_event_handler.py @@ -1,7 +1,7 @@ # Copyright (C) 2018 Avatao.com Innovative Learning Kft. # All Rights Reserved. See LICENSE file for details. -from tfw import TriggerlessEventHandler +from tfw import EventHandlerBase from tfw.config import TFWENV from tfw.config.logs import logging from tao.config import TAOENV @@ -10,7 +10,7 @@ from .terminado_mini_server import TerminadoMiniServer LOG = logging.getLogger(__name__) -class TerminadoEventHandler(TriggerlessEventHandler): +class TerminadoEventHandler(EventHandlerBase): def __init__(self, key, monitor): super().__init__(key) self.working_directory = TFWENV.TERMINADO_DIR diff --git a/lib/tfw/components/webide_event_handler.py b/lib/tfw/components/webide_event_handler.py index 9a007a2..5ebd6e9 100644 --- a/lib/tfw/components/webide_event_handler.py +++ b/lib/tfw/components/webide_event_handler.py @@ -6,7 +6,7 @@ from glob import glob from fnmatch import fnmatchcase from collections import Iterable -from tfw import TriggerlessEventHandler +from tfw import EventHandlerBase from tfw.mixins import MonitorManagerMixin from tfw.config.logs import logging from .directory_monitor import DirectoryMonitor @@ -91,7 +91,7 @@ class FileManager: # pylint: disable=too-many-instance-attributes return relpath(self._filepath(filename), start=self._workdir) -class WebideEventHandler(TriggerlessEventHandler, MonitorManagerMixin): +class WebideEventHandler(EventHandlerBase, MonitorManagerMixin): # pylint: disable=too-many-arguments def __init__(self, key, directory, allowed_directories, selected_file=None, exclude=None): super().__init__(key) diff --git a/lib/tfw/event_handler_base.py b/lib/tfw/event_handler_base.py index 46a42e8..5f07965 100644 --- a/lib/tfw/event_handler_base.py +++ b/lib/tfw/event_handler_base.py @@ -24,16 +24,10 @@ class EventHandlerBase(ABC): return self.server_connector.send(response) - @abstractmethod def dispatch_handling(self, message): - raise NotImplementedError - - def _dispatch_handling(self, message): - # pylint: disable=no-else-return if message['key'] != 'reset': return self.handle_event(message) - else: - return self.handle_reset(message) + return self.handle_reset(message) @abstractmethod def handle_event(self, message): @@ -64,12 +58,6 @@ class EventHandlerBase(ABC): self.subscriptions.clear() -class TriggerlessEventHandler(EventHandlerBase, ABC): - # pylint: disable=abstract-method - def dispatch_handling(self, message): - return self._dispatch_handling(message) - - class TriggeredEventHandler(EventHandlerBase, ABC): # pylint: disable=abstract-method def __init__(self, key, trigger): @@ -78,5 +66,5 @@ class TriggeredEventHandler(EventHandlerBase, ABC): def dispatch_handling(self, message): if message.get('trigger') == self.trigger: - return self._dispatch_handling(message) + return super().dispatch_handling(message) return None