From 65c8bcee2b780db649888be7694cbc0119f673cd Mon Sep 17 00:00:00 2001 From: "R. Richard" Date: Mon, 24 Jun 2019 14:24:59 +0200 Subject: [PATCH] Remove DirectoryMonitoringEventHandler --- lib/tfw/builtins/__init__.py | 1 - .../directory_monitoring_event_handler.py | 70 ------------------- 2 files changed, 71 deletions(-) delete mode 100644 lib/tfw/builtins/directory_monitoring_event_handler.py diff --git a/lib/tfw/builtins/__init__.py b/lib/tfw/builtins/__init__.py index 7e94f10..9061f3d 100644 --- a/lib/tfw/builtins/__init__.py +++ b/lib/tfw/builtins/__init__.py @@ -1,4 +1,3 @@ -from .directory_monitoring_event_handler import DirectoryMonitoringEventHandler from .directory_snapshotting_event_handler import DirectorySnapshottingEventHandler from .frontend_event_handler import FrontendEventHandler from .fsm_managing_event_handler import FSMManagingEventHandler diff --git a/lib/tfw/builtins/directory_monitoring_event_handler.py b/lib/tfw/builtins/directory_monitoring_event_handler.py deleted file mode 100644 index 222736c..0000000 --- a/lib/tfw/builtins/directory_monitoring_event_handler.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2018 Avatao.com Innovative Learning Kft. -# All Rights Reserved. See LICENSE file for details. - -import logging -from os.path import isdir, exists - -from tfw.event_handlers import FrontendEventHandlerBase -from tfw.mixins.monitor_manager_mixin import MonitorManagerMixin -from tfw.components.directory_monitor import DirectoryMonitor - -LOG = logging.getLogger(__name__) - - -class DirectoryMonitoringEventHandler(FrontendEventHandlerBase, MonitorManagerMixin): - def __init__(self, key, directory): - super().__init__(key) - self._directory = directory - MonitorManagerMixin.__init__( - self, - DirectoryMonitor, - key, - self._directory - ) - - self.commands = { - 'pause': self.pause, - 'resume': self.resume, - 'ignore': self.ignore, - 'selectdir': self.selectdir - } - - @property - def directory(self): - return self._directory - - @directory.setter - def directory(self, directory): - if not exists(directory) or not isdir(directory): - raise EnvironmentError('No such directory!') - self._directory = directory - - def handle_event(self, message): - try: - message['data'] = self.commands[message['data']['command']](message['data']) - return message - except KeyError: - LOG.error('IGNORING MESSAGE: Invalid message received: %s', message) - - def pause(self, data): - self.monitor.pause() - return data - - def resume(self, data): - self.monitor.resume() - return data - - def ignore(self, data): - self.monitor.ignore += data['ignore'] - return data - - def selectdir(self, data): - try: - self.directory = data['directory'] - self.reload_monitor() - return data - except EnvironmentError: - LOG.error('Failed to switch directory!') - - def cleanup(self): - self.monitor.stop()