Linux inotify wrapper
Project description
inotify_lite
inotify_lite is a Python 3.8 wrapper around inotify (see inotify(7)).
Usage
Classes
IN_FLAGS
class IN_FLAGS(enum.IntFlag)
Wrapper around the underlying C lib flags. See inotify_add_watch(2), <sys/inotify.h>
, <bits/inotify.h>
.
Event
namedtuple("Event", ("wd", "mask", "cookie", "len", "name"))
Maps the underlying struct inotify_event
. See inotify_add_watch(2).
Inotify
Inotify(
callback: Callable[[Sequence[Event]], Any],
*files: str,
blocking: bool = True,
flags: IN_FLAGS = 0,
)
Base class for TreeWatcher
and FileWatcher
.
TreeWatcher
TreeWatcher(
callback: Callable[[Sequence[Event]], Any],
*dirs: str,
blocking: bool = True,
watch_all: bool = True,
flags: IN_FLAGS = 0,
)
Watch directories. Extends Inotify
and passes IN_FLAGS.ONLYDIR
by default (raises if any of dirs
is not a directory). The watch_all
option means to watch for all filesystem events (this can be quite noisy).
FileWatcher
FileWatcher(
callback: Callable[[Sequence[Event]], Any],
*files: str,
blocking: bool = True,
watch_all: bool = True,
flags: IN_FLAGS = 0,
)
Watch files.
Examples
To watch a directory:
def my_callback(events):
# Just show me the event mask.
for e in events:
print(IN_FLAGS(e.mask))
# Watch the home directory for successful writes.
watcher = TreeWatcher(my_callback, "~", watch_all=False, flags=IN_FLAGS.CLOSE_WRITE)
watcher.watch()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
inotify_lite-0.0.2.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for inotify_lite-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e37dec7cdd8fef9fccbd42f256f5bf3fee08f10736c067e548945072fbdadd3d |
|
MD5 | 53c821b99177a40d5eda4c7a5ac9b02a |
|
BLAKE2b-256 | 0fe9ddbfa3bdc65d802cc55bc37f7aa12f191d3bd13e104b7bf74b9fb828fb33 |