cement.ext.ext_watchdog

Cement watchdog extension module.

Note This extension has an external dependency on watchdog. Cement explicitly does not include external dependencies for optional extensions.

  • In Cement >=3.0.8 you must include cement[watchdog] in your applications dependencies.

  • In Cement <3.0.8 you must include watchdog in your applications dependencies.

class cement.ext.ext_watchdog.WatchdogEventHandler(app, *args, **kw)[source]

Bases: FileSystemEventHandler

Default event handler used by Cement, that logs all events to the application’s debug log. Additional *args and **kwargs are passed to the parent class.

Parameters:

app – The application object

on_any_event(event)[source]

Catch-all event handler.

Parameters:

event (FileSystemEvent) – The event object representing the file system event.

class cement.ext.ext_watchdog.WatchdogManager(app, *args, **kw)[source]

Bases: MetaMixin

The manager class that is attached to the application object via App.extend().

Usage:

with MyApp() as app:
    app.watchdog.start()
    app.watchdog.stop()
    app.watchdog.join()
add(path, event_handler=None, recursive=True)[source]

Add a directory path and event handler to the observer.

Parameters:

path (str) – A directory path to monitor (str)

Keyword Arguments:
  • event_handler (class) – An event handler class used to handle events for path (class)

  • recursive (bool) – Whether to monitor the path recursively

Returns:

True if the path is added, False otherwise.

Return type:

bool

join(*args, **kw)[source]

Join the observer with the parent process. All *args and **kwargs are passed down to the backend observer.

start(*args, **kw)[source]

Start the observer. All *args and **kwargs are passed down to the backend observer.

stop(*args, **kw)[source]

Stop the observer. All *args and **kwargs are passed down to the backend observer.