cowbird.monitoring.monitoring
¶
Module Contents¶
Classes¶
Implementation of the watchdog FileSystemEventHandler class Allows to start/stop directory monitoring and send |
|
Class handling file system monitoring and registering listeners. |
-
class
cowbird.monitoring.monitoring.
Monitor
(: str, path: bool, recursive: cowbird.monitoring.fsmonitor.FSMonitor, callback)[source]¶ Bases:
watchdog.events.FileSystemEventHandler
Implementation of the watchdog FileSystemEventHandler class Allows to start/stop directory monitoring and send events to FSMonitor callback.
Todo
This class should be mapped as a BD model (we need to persist monitors across executions)
Initialize the path monitoring and ready to be started.
Todo
To serialize the callback we would need an actual singleton class name
@param path: Path to monitor @param recursive: Monitor subdirectory recursively? @param callback: Events are sent to this FSMonitor object
-
on_moved
(self: Union[watchdog.events.DirMovedEvent, watchdog.events.FileMovedEvent], event) → None[source]¶ Called when a file or a directory is moved or renamed.
@param event: Event representing file/directory movement.
-
on_created
(self: Union[watchdog.events.DirCreatedEvent, watchdog.events.FileCreatedEvent], event) → None[source]¶ Called when a file or directory is created.
@param event: Event representing file/directory creation.
-
-
class
cowbird.monitoring.monitoring.
Monitoring
[source]¶ Class handling file system monitoring and registering listeners.
Todo
At some point we will need a consistency function that goes through all monitored folder and make sure that monitoring services are up to date.
-
register
(self: str, path: bool, recursive: cowbird.monitoring.fsmonitor.FSMonitor, cb_monitor) → None[source]¶ Register a monitor for a specific path and start it.
@param path: Path to monitor @param recursive: Monitor subdirectory recursively? @param cb_monitor: Events are sent to this FSMonitor object
-
unregister
(self: str, path: cowbird.monitoring.fsmonitor.FSMonitor, cb_monitor) → bool[source]¶ Stop a monitor and unregister it.
@param path: Path used by the monitor @param cb_monitor: FSMonitor object to remove @return: True if the monitor is found and successfully stopped, False otherwise
-