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,
all_events: 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 all_events
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,
all_events: 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, "~", all_events=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.1.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for inotify_lite-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c9694ca286765b60135ef9889abccd8abe9a3b31f7396528ab8fbfbcd34af9c |
|
MD5 | b025d2e0a0914323ba11c9b880174299 |
|
BLAKE2b-256 | e96f00d89ca2b7b909df2a2bf258951ecd205cfff042dd679c29ecc84e970822 |