Skip to main content

No project description provided

Project description

panzi-inotify

API Documentation

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_INOTIFY false and only if you try to create an instance of Inotify you will get an exception (OSError(ENOSYS)).
  • It correctly handles paths that are invalid UTF-8 by using the 'surrogateescape' escape Unicode error handling option. This makes the file paths rountrip safe.
  • wait() and read_events() is separate. You can do your own wait/poll logic if you want.
  • read_events() only reads the available events. If there are none at the moment it returns an empty array.
  • You can pass a stopfd to Inotify(). This file descriptor will be added to epoll_wait() call in Inotify.wait(). If POLLIN signals for that wait() will return False. This is meant for implementing a way to stop a process that waits for events without a timeout.
  • Translates errors in the approprioate Python exceptions from the given errno (FileNotFoundError etc. and OSError as fallback).

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

inotify(7)

License

Mozilla Public License Version 2.0

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

panzi_inotify-1.0.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panzi_inotify-1.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file panzi_inotify-1.0.0.tar.gz.

File metadata

  • Download URL: panzi_inotify-1.0.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for panzi_inotify-1.0.0.tar.gz
Algorithm Hash digest
SHA256 21d06320faab949a84ed1a2592c69be92cd037c7a7ad384fb10b714c557f9fa8
MD5 421e41bdab746b735d816d9176c64df5
BLAKE2b-256 7ed44bb4a04b55a82e6d873609c171ccdbe84992e226e38ea1ef01a3b79363e4

See more details on using hashes here.

File details

Details for the file panzi_inotify-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for panzi_inotify-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 765978d52314208ff96fa96302eb584670ada1425f6596f144f378fdac9abd8a
MD5 6c86e89b8fc171cb0fc399d7e695637c
BLAKE2b-256 c69e8ed14257a64aee9ae20fe473c20b49872b253a45b7fadd5a69e420dbe241

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page