Remove DirectoryMonitoringEventHandler

This commit is contained in:
R. Richard 2019-06-24 14:24:59 +02:00 committed by Kristóf Tóth
parent d031f481b8
commit 65c8bcee2b
2 changed files with 0 additions and 71 deletions

View File

@ -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

View File

@ -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()