_LOG_HANDLER_ADDED = False
+ """ Abstract base class.
+ Provides core DirWatcher event handling, startup and shutdown interfaces.
+ Actual work, like monitoring for file events, should be done by derivative classes.
+ It is expected that the derivative classes will pass file events it sees to
+ the monitor_events queue. Each of these events is expected to appear in the form of
+ a tuple-like object with at least 3 fields:
+ (timestamp, path, event_id)
+ Where event_id is one of the supported 'EV_*' event types in the eventtype module.
+ These events will be dispatched from the queue in order of arrival to any interested
+ listeners, via the EventManager.
+ Interested listeners subscribe by registering a callable, and the event_id(s) they want,
+ with the EventManager, self.events.
self.events = EventManager([event_name for event_name in dir(eventtype)
_LOG_HANDLER_ADDED = True
+ """ Core event dispatcher.
+ Receives filesystem events from the monitor(s), and
+ broadcasts them to interested listeners via the EventManager.
event = self.monitor_events.get()
+ """ Begin watching the directories, given in self.paths, for events.
+ Subsequent calls, if the montior is already active, will be ignored, and
+ True, if the monitor starts successfully.
+ NOTE: This base-class routine simply sets some state, and broadcasts
+ a eventtype.EV_MONITOR_STARTED message. The descendant classes
+ are expected to then start whatever monitoring mechanism they have
assert self._worker_thread is None
+ """ Stop the event monitor.
+ NOTE: This base-class routine simply resets the state (set by start_monitor),
+ and broadcasts a eventtype.EV_MONITOR_STOPPED message.
+ Descendant is expected to cleanly shutdown its monitoring mechanism.
""" Builds a set of filepaths in the given directory.
Intension is to be able to find before/after differences, when
- there are too many events to process.
+ there are too many events to process for our monitor, and we need
+ to refresh our view to catch up.
for path, subdirs, filenames in os.walk(directory):