mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 16:51:31 +00:00
Move TriggerlessEventHandler logic to base class EventHandlerBase
This commit is contained in:
parent
c909317ca0
commit
690f9bb190
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -24,15 +24,9 @@ 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)
|
||||
|
||||
@abstractmethod
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user