cowbird.monitoring.monitoring

Module Contents

Classes

Monitor

Implementation of the watchdog FileSystemEventHandler class Allows to start/stop directory monitoring and send

Monitoring

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

save(self)[source]
remove(self)[source]
start(self)[source]

Start the monitoring so that events can be fired.

stop(self)[source]

Stop the monitoring so that events stop to be fired.

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.

on_deleted(self: Union[watchdog.events.DirDeletedEvent, watchdog.events.FileDeletedEvent], event)None[source]

Called when a file or directory is deleted.

@param event: Event representing file/directory deletion.

on_modified(self: Union[watchdog.events.DirModifiedEvent, watchdog.events.FileModifiedEvent], event)None[source]

Called when a file or directory is modified.

@param event: Event representing file/directory modification.

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.

start(self)[source]

Todo

Load and start monitors from the BD

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