panzi-inotify
Simple inotify bindings for Python.
I didn't like all the other available inotify bindings for one reason or anther. This one is different in these ways:
- You can import the module even if your libc doesn't support inotify. It then
will have
HAS_INOTIFYFalseand only if you try to create an instance ofInotifyyou will get an exception (OSError(ENOSYS)). - It correctly handles paths that are invalid UTF-8 by using
os.fsencode()/os.fsdecode()which use the'surrogateescape'Unicode error handling option. This makes the file paths rountrip safe. wait()andread_events()is separate. You can do your own wait/poll logic if you want.- You can use non-blocking mode and then
read_events()only reads the available events. If there are none at the moment it returns an empty array. - You can pass a
stopfdtoPollInotify(). This file descriptor will be added to theepoll_wait()call inPollInotify.wait(). IfPOLLINsignals for that thenwait()will returnFalse. This is meant for implementing a way to stop a thread that waits for events without a timeout. - Translates errors to the appropriate Python exceptions from the given
errno(FileNotFoundError,PermissionErroretc. andOSErroras fallback). - Uses Mozilla Public License Version 2.0, so you can use it from proprietary code, yet it isn't as permissive as MIT or BSD.
Installation
Via pip:
$ pip install panzi-inotify
Form source:
$ git clone git@github.com:panzi/panzi-inotify.git
$ pip install ./panzi-inotify
Example
from panzi_inotify import Inotify, get_inotify_event_names
import sys
with Inotify() as inotify:
for filename in sys.argv[1:]:
inotify.add_watch(filename)
for event in inotify:
print(f'{event.full_path()}: {", ".join(get_inotify_event_names(event.mask))}')
See examples for more.
You can also run a basic command line too to listen for events on a set of paths like this:
python -m panzi_inotify [--mask=MASK] <path>...
For more on this see:
python -m panzi_inotify --help
See Also
Metadata
Release files for panzi_inotify 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| panzi_inotify-1.0.3.tar.gz | 17.9 kB | Without provenance | Details for panzi_inotify-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| panzi_inotify-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for panzi_inotify-1.0.3-py3-none-any.whl |
Total release size: 35.0 kB
Release files / panzi_inotify-1.0.3.tar.gz
| Download URL | panzi_inotify-1.0.3.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfdccb26b02ec4af0a6413138d83a52e6360c51751dea7422e0da44ac6f8cb3f
|
|
BLAKE2b-256 checksum How to use checksums |
84790395526ac8d465e7eb48cf4a334a0a6fe4f9a8f95be7f0b8ac91629fcb25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / panzi_inotify-1.0.3-py3-none-any.whl
| Download URL | panzi_inotify-1.0.3-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
206629eef0399d815df4fe1dbc7b3d0df9aebbbd0f5d89260cc9be1df29a30b8
|
|
BLAKE2b-256 checksum How to use checksums |
862f108d329457b5afed1b1c4305858cfabd82205e9d8677049f0682b0341d6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Security for panzi_inotify 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.