Refactor MonitorManagerMixin to allow arbitrary Monitor arguments

This commit is contained in:
Kristóf Tóth 2018-05-30 13:06:09 +02:00
parent 28c16e1127
commit 9e6cd57532

View File

@ -7,10 +7,10 @@ LOG = logging.getLogger(__name__)
class MonitorManagerMixin: class MonitorManagerMixin:
def __init__(self, monitor_type, directories): def __init__(self, monitor_type, *monitor_args):
self._monitor_type = monitor_type self._monitor_type = monitor_type
self._monitor = None self._monitor = None
self._monitored_directories = directories self._monitor_args = monitor_args
self.reload_monitor() self.reload_monitor()
@property @property
@ -23,5 +23,5 @@ class MonitorManagerMixin:
self._monitor.stop() self._monitor.stop()
except KeyError: except KeyError:
LOG.debug('Working directory was removed ignoring...') LOG.debug('Working directory was removed ignoring...')
self._monitor = self._monitor_type(self._monitored_directories) self._monitor = self._monitor_type(*self._monitor_args)
self._monitor.watch() # This runs on a separate thread self._monitor.watch() # This runs on a separate thread