cowbird.monitoring.monitoring

Module Contents

Classes

Monitoring

Class handling file system monitoring and registering listeners.

Attributes

LOGGER

cowbird.monitoring.monitoring.LOGGER[source]
exception cowbird.monitoring.monitoring.MonitoringConfigurationException[source]

Bases: Exception

Exception thrown when the monitoring instance cannot be initialized because of a bad configuration.

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

class cowbird.monitoring.monitoring.Monitoring(config: cowbird.typedefs.AnySettingsContainer = None)[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 handlers are up to date.

Initialize the monitoring instance from configured application settings.

Parameters

config – AnySettingsContainer object from which the db can be retrieved. The default value of None is only there to disable pylint E1120. The singleton instance must be initialized with a proper config and after that the init function should not be hit.

start()[source]

Load existing monitors and start the monitoring.

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

Register a monitor for a specific path and start it. If a monitor already exists for the specific path/cb_monitor combination it is directly returned. If this monitor was not recursively monitoring its path and the recursive flag is now true, this one take precedence and the monitor is updated accordingly. If the recursive flag was true and now it is false it has no effect.

Parameters
  • path – Path to monitor

  • recursive – Monitor subdirectory recursively?

  • cb_monitor – FSMonitor for which an instance is created and events are sent Can be an object, a class type implementing FSMonitor or a string containing module and class name.

Returns

The monitor registered or already existing for the specific path/cb_monitor combination.

unregister(path: str, cb_monitor: Union[cowbird.monitoring.fsmonitor.FSMonitor, Type[cowbird.monitoring.fsmonitor.FSMonitor], str])bool[source]

Stop a monitor and unregister it.

Parameters
  • path – Path used by the monitor

  • cb_monitor – FSMonitor object to remove Can be an object, a class type implementing FSMonitor or a string containing module and class name.

Returns

True if the monitor is found and successfully stopped, False otherwise