cowbird.monitoring.monitor ========================== .. py:module:: cowbird.monitoring.monitor Attributes ---------- .. autoapisummary:: cowbird.monitoring.monitor.LOGGER cowbird.monitoring.monitor.MonitorKey cowbird.monitoring.monitor.MonitorParameters Exceptions ---------- .. autoapisummary:: cowbird.monitoring.monitor.MonitorException Classes ------- .. autoapisummary:: cowbird.monitoring.monitor.Monitor Module Contents --------------- .. py:data:: LOGGER .. py:data:: MonitorKey .. py:data:: MonitorParameters .. py:exception:: MonitorException Bases: :py:obj:`Exception` Error indicating that a :class:`Monitor` cannot be started because of an invalid path or callback. Initialize self. See help(type(self)) for accurate signature. .. py:class:: Monitor(path: str, recursive: bool, callback: Union[cowbird.monitoring.fsmonitor.FSMonitor, Type[cowbird.monitoring.fsmonitor.FSMonitor], str]) Bases: :py:obj:`watchdog.events.FileSystemEventHandler` Implementation of the watchdog :class:`FileSystemEventHandler` class Allows to start/stop directory monitoring and send events to :class:`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 :class:`FSMonitor` or a string containing module and class name. The class type or string is used to instantiate an object using the class method :meth:`FSMonitor.get_instance()` .. py:attribute:: __src_path .. py:attribute:: __recursive .. py:attribute:: __callback .. py:attribute:: __event_observer :type: Optional[watchdog.observers.api.BaseObserver] :value: None .. py:method:: get_fsmonitor_instance(callback: Union[cowbird.monitoring.fsmonitor.FSMonitor, Type[cowbird.monitoring.fsmonitor.FSMonitor], str]) -> cowbird.monitoring.fsmonitor.FSMonitor :staticmethod: Return a :class:`FSMonitor` instance from multiple possible forms including the :class:`FSMonitor` type, the :class:`FSMonitor` full qualified class name or a direct instance which is returned as is. .. py:method:: get_qualified_class_name(monitor: cowbird.monitoring.fsmonitor.FSMonitor) -> str :staticmethod: Returns the full qualified class name of the :class:`FSMonitor` object (string of the form module.class_name) .. py:property:: recursive :type: bool .. py:property:: path :type: str .. py:property:: callback :type: str .. py:property:: callback_instance :type: cowbird.monitoring.fsmonitor.FSMonitor .. py:property:: key :type: MonitorKey Return a dict that can be used as a unique key to identify this :class:`Monitor` in a BD. .. py:property:: is_alive :type: bool Returns true if the monitor observer exists and is currently running. .. py:method:: params() -> MonitorParameters Return a dict serializing this object from which a new :class:`Monitor` can be recreated using the init function. .. py:method:: start() -> None Start the monitoring so that events can be fired. .. py:method:: stop() -> None Stop the monitoring so that events stop to be fired. .. py:method:: on_moved(event: Union[watchdog.events.DirMovedEvent, watchdog.events.FileMovedEvent]) -> None Called when a file or a directory is moved or renamed. :param event: Event representing file/directory movement. .. py:method:: on_created(event: Union[watchdog.events.DirCreatedEvent, watchdog.events.FileCreatedEvent]) -> None Called when a file or directory is created. :param event: Event representing file/directory creation. .. py:method:: on_deleted(event: Union[watchdog.events.DirDeletedEvent, watchdog.events.FileDeletedEvent]) -> None Called when a file or directory is deleted. :param event: Event representing file/directory deletion. .. py:method:: on_modified(event: Union[watchdog.events.DirModifiedEvent, watchdog.events.FileModifiedEvent]) -> None Called when a file or directory is modified. :param event: Event representing file/directory modification.