cowbird.monitoring.monitor

Module Contents

Classes

Monitor

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

Attributes

LOGGER

cowbird.monitoring.monitor.LOGGER[source]
exception cowbird.monitoring.monitor.MonitorException[source]

Bases: Exception

Error indicating that a Monitor cannot be started because of an invalid path or callback.

Initialize self. See help(type(self)) for accurate signature.

class cowbird.monitoring.monitor.Monitor(path: bool, recursive: Union[cowbird.monitoring.fsmonitor.FSMonitor, Type[cowbird.monitoring.fsmonitor.FSMonitor], str], callback)[source]

Bases: watchdog.events.FileSystemEventHandler

Implementation of the watchdog FileSystemEventHandler class Allows to start/stop directory monitoring and send events to FSMonitor callback.

Initialize the path monitoring and ready to be started.

@param path: Path to monitor @param recursive: Monitor subdirectory recursively? @param callback: Events are sent to this FSMonitor.

Can be an object, a class type implementing FSMonitor or a string containing module and class name. The class type or string is used to instantiate an object using the class method FSMonitor.get_instance()

static get_fsmonitor_instance(callback: Union[cowbird.monitoring.fsmonitor.FSMonitor, Type[cowbird.monitoring.fsmonitor.FSMonitor], str])cowbird.monitoring.fsmonitor.FSMonitor[source]

Return a FSMonitor instance from multiple possible forms including the FSMonitor type, the FSMonitor full qualified class name or a direct instance which is returned as is.

static get_qualified_class_name(monitor: cowbird.monitoring.fsmonitor.FSMonitor)str[source]

Returns the full qualified class name of the FSMonitor object (string of the form module.class_name)

property recursive(self)[source]
property path(self)[source]
property callback(self)[source]
property callback_instance(self)[source]
property key(self)Dict[source]

Return a dict that can be used as a unique key to identify this Monitor in a BD.

params(self)Dict[source]

Return a dict serializing this object from which a new Monitor can be recreated using the init function.

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.