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).

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

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.1.tar.gz (16.9 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.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for panzi_inotify-1.0.1.tar.gz
Algorithm Hash digest
SHA256 203aad56f67a802f4d9f6ae01f101e1ae8226833a3f4672e61e399058c03e4a4
MD5 1a99a5dbdc6a756d3b41ba33ccf9ba97
BLAKE2b-256 f650f3807aad91252f05489fdefb2dca2472fa7a35e96f075c230782fd0f62ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for panzi_inotify-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fcdce74176809a42d9a8e93d28ed5abbbe800186e668b02e51559405046134b0
MD5 6ed111cc601a000570f9f52dae5540dc
BLAKE2b-256 14af4abeca3e5f42320e6c645dc3279ef8a0aff44681636869e19d2f900ec2e9

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