diff --git a/README.md b/README.md index 474d4e6..5720087 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # pyinotifyd -A daemon to monitore filesystems events with inotify on Linux and execute tasks, which can be Python functions or shell commands. +A daemon to monitore filesystems events with inotify on Linux and execute tasks, which can be Python functions or shell commands. It is build on top of the pyinotify library. -## Dependencies +## Requirements * [pyinotify](https://github.com/seb-m/pyinotify) ## Installation @@ -16,16 +16,21 @@ The config file is written in Python syntax. pyinotifyd reads config options fro This is the default configuration: ```python pyinotifyd_config = { + # List of watches, description below "watches": [], + # Set the loglevel (see https://docs.python.org/3/library/logging.html#levels) "loglevel": logging.INFO, + # Set the timeout to wait for pending tasks to complete during shutdown "shutdown_timeout": 30 } ``` - -Global options: -* **watches** - List of Watches, description below. -* **loglevel** - Set the loglevel, you may use every available loglevel of the Python logging framework. -* **shutdown_timeout** - Timeout to wait for pending tasks to complete when shutdown. +## Watch configuration +A Watch is defined as a dictionary which contains the config options: +```python +{ + "path": "/tmp", + "rec": True, + "auto_add": True, + "event_map": {} +} +``` diff --git a/docs/.config.py.swp b/docs/.config.py.swp new file mode 100644 index 0000000..5b59b1c Binary files /dev/null and b/docs/.config.py.swp differ diff --git a/pyinotifyd.py b/pyinotifyd.py index 8aef052..61f0256 100755 --- a/pyinotifyd.py +++ b/pyinotifyd.py @@ -67,11 +67,11 @@ class Task: class TaskScheduler: - def __init__(self, job, delay=0, files=True, directories=False, + def __init__(self, job, delay=0, files=True, dirs=False, logname="TaskScheduler"): self._delay = delay self._files = files - self._directories = directories + self._dirs = dirs self._job = job self._tasks = {} self._log = logging.getLogger(logname) @@ -86,7 +86,7 @@ class TaskScheduler: path = event.pathname maskname = event.maskname.split("|", 1)[0] if (not event.dir and not self._files) or \ - (event.dir and not self._directories): + (event.dir and not self._dirs): return if path in self._tasks: