change README.md

This commit is contained in:
2020-11-03 21:32:04 +01:00
parent f2b6f1e0b6
commit d7adaf3362
2 changed files with 35 additions and 10 deletions

View File

@@ -62,6 +62,22 @@ This is an example:
event_map = EventMap({"IN_CLOSE_NOWRITE": [s.schedule, s1.schedule],
"IN_CLOSE_WRITE": s.schedule})
```
The following event types are available:
* **IN_ACCESS**: a file was accessed
* **IN_ATTRIB**: a metadata changed
* **IN_CLOSE_NOWRITE**: an unwritable file was closed
* **IN_CLOSE_WRITE**: a writable file was closed
* **IN_CREATE**: a file/directory was created
* **IN_DELETE**: a file/directory was deleted
* **IN_DELETE_SELF**: a watched item itself was deleted
* **IN_IGNORED**: raised when a watch is removed, probably useless for you
* **IN_MODIFY**: a file was modified
* **IN_MOVE_SELF**: a watched item was moved, currently its full pathname destination can only be known if its source and destination directories were both watched. Otherwise, the file is still being watched but you cannot rely anymore on the given path attribute *event.path*
* **IN_MOVED_FROM**: a file/directory in a watched directory was moved from another specified watched directory. Can trace the full move of an item when IN_MOVED_TO is available too, in this case if the moved item is itself watched, its path will be updated (see IN_MOVE_SELF)
* **IN_MOVED_TO**: a file/directory was moved to another specified watched directory (see IN_MOVE_FROM)
* **IN_OPEN**: a file was opened
* **IN_Q_OVERFLOW**: the event queue overflown. This event is not associated with any watch descriptor
* **IN_UNMOUNT**: when backing filesystem was unmounted. Notified to each watch of this filesystem
### Watches
Watch watches *path* for event types in *event_map* and execute the corresponding task(s). If *rec* is True, a watch will be added on each subdirectory in *path*. If *auto_add* is True, a watch will be added automatically on newly created subdirectories in *path*.
@@ -75,6 +91,16 @@ pyinotifyd expects an instance of PyinotifydConfig named **pyinotifyd_config** t
pyinotifyd_config = PyinotifydConfig(watches=[watch], loglevel=logging.INFO, shutdown_timeout=30)
```
### Autostart
pyinotifyd provides a systemd service file.
```sh
# start pyinotifyd at boot time
systemctl enable pyinotifyd.service
# start the daemon immediately
systemctl start pyinotifyd.service
```
## Examples
### Schedule Python task for all events
@@ -137,13 +163,3 @@ watch = Watch(path="/src_path", event_map=event_map, rec=True, auto_add=True)
pyinotifyd_config = PyinotifydConfig(
watches=[watch], loglevel=logging.INFO, shutdown_timeout=35)
```
### Autostart
pyinotifyd provides a systemd service file.
```sh
# start pyinotifyd at boot time
systemctl enable pyinotifyd.service
# start the daemon immediately
systemctl start pyinotifyd.service
```

View File

@@ -404,6 +404,11 @@ def main():
"--debug",
help="log debugging messages",
action="store_true")
parser.add_argument(
"-e",
"--events",
help="show event types and exit",
action="store_true")
parser.add_argument(
"-v",
"--version",
@@ -414,6 +419,10 @@ def main():
if args.version:
print(f"{myname} ({__version__})")
sys.exit(0)
elif args.events:
types = "\n".join(EventMap.flags.keys())
print(types)
sys.exit(0)
log = logging.getLogger(myname)