mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-25 08:51:31 +00:00
Use power of LazyInitialise to replace ObserverMixin.__init__()
This commit is contained in:
parent
9f3a3b501f
commit
cebacb15e6
@ -16,7 +16,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class DirectoryMonitor(ObserverMixin):
|
class DirectoryMonitor(ObserverMixin):
|
||||||
def __init__(self, directories):
|
def __init__(self, directories):
|
||||||
ObserverMixin.__init__(self)
|
|
||||||
self.eventhandler = IdeReloadWatchdogEventHandler()
|
self.eventhandler = IdeReloadWatchdogEventHandler()
|
||||||
for directory in directories:
|
for directory in directories:
|
||||||
self.observer.schedule(self.eventhandler, directory, recursive=True)
|
self.observer.schedule(self.eventhandler, directory, recursive=True)
|
||||||
|
@ -37,7 +37,6 @@ class HistoryMonitor(CallbackMixin, ObserverMixin, ABC):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, histfile):
|
def __init__(self, histfile):
|
||||||
CallbackMixin.__init__(self)
|
CallbackMixin.__init__(self)
|
||||||
ObserverMixin.__init__(self)
|
|
||||||
self.histfile = histfile
|
self.histfile = histfile
|
||||||
self._history = []
|
self._history = []
|
||||||
self._last_length = len(self._history)
|
self._last_length = len(self._history)
|
||||||
|
@ -14,7 +14,6 @@ from tfw.mixins import ObserverMixin, SupervisorLogMixin
|
|||||||
class LogMonitor(ObserverMixin):
|
class LogMonitor(ObserverMixin):
|
||||||
def __init__(self, process_name, log_tail=0):
|
def __init__(self, process_name, log_tail=0):
|
||||||
self.prevent_log_recursion()
|
self.prevent_log_recursion()
|
||||||
ObserverMixin.__init__(self)
|
|
||||||
event_handler = SendLogWatchdogEventHandler(process_name, log_tail=log_tail)
|
event_handler = SendLogWatchdogEventHandler(process_name, log_tail=log_tail)
|
||||||
self.observer.schedule(
|
self.observer.schedule(
|
||||||
event_handler,
|
event_handler,
|
||||||
|
@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
from watchdog.observers import Observer
|
from watchdog.observers import Observer
|
||||||
|
|
||||||
|
from tfw.decorators import LazyInitialise
|
||||||
|
|
||||||
|
|
||||||
class ObserverMixin:
|
class ObserverMixin:
|
||||||
def __init__(self):
|
@LazyInitialise
|
||||||
self.observer = Observer()
|
def observer(self):
|
||||||
|
return Observer()
|
||||||
|
|
||||||
def watch(self):
|
def watch(self):
|
||||||
self.observer.start()
|
self.observer.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user