mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 18:41:32 +00:00
Remove DirectoryMonitoringEventHandler
This commit is contained in:
parent
d031f481b8
commit
65c8bcee2b
@ -1,4 +1,3 @@
|
|||||||
from .directory_monitoring_event_handler import DirectoryMonitoringEventHandler
|
|
||||||
from .directory_snapshotting_event_handler import DirectorySnapshottingEventHandler
|
from .directory_snapshotting_event_handler import DirectorySnapshottingEventHandler
|
||||||
from .frontend_event_handler import FrontendEventHandler
|
from .frontend_event_handler import FrontendEventHandler
|
||||||
from .fsm_managing_event_handler import FSMManagingEventHandler
|
from .fsm_managing_event_handler import FSMManagingEventHandler
|
||||||
|
@ -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()
|
|
Loading…
Reference in New Issue
Block a user