Skip to main content

Linux inotify wrapper

Project description

Documentation Status

inotify_lite

inotify_lite provides a Python 3 wrapper around the Linux inotify API. This lets you monitor filesystem events, and execute callbacks. See inotify(7).

Requires

  • Linux >= 2.6.13 (or glibc >= 2.5)

  • Python >= 3.6

Installation

Install inotify_lite by running:

pip install inotify_lite

Usage

To use inotify_lite:

  • Create an Inotify instance, passing the name of the files (or directories) you wish to watch;

  • Register a handler (or many), a callable of two arguments:

    • an Inotify instance; and

    • an InotifyEvent instance.

  • call Inotify.read to read once, or Inotify.watch to watch until a keyboard interrupt is received.

Examples:

def my_callback(_, event):
    print(event.name)
    print(event.mask)

flags = INFlags.CREATE | INFlags.DELETE
watcher = Inotify("/home/", watch_flags=flags)
watcher.register_handler(INFlags.ALL_FLAGS, my_callback, exclusive=False)
watcher.watch()
def my_callback(_, event):
    print(event.name)
    print(event.mask)

watcher = TreeWatcher("/home/", watch_flags=INFlags.OPEN, timeout=10)
# Watch the home directory for OPEN events with a 10 second timeout.

watcher.register_handler(INFlags.ALL_FLAGS, my_callback, exclusive=False)
watcher.read_once()

The TreeWatcher class is provided to recursively watch directories.

See the documentation for details and options.

Contribute

Contributions are welcome. Open an issue for visibility.

To install the dev requirements run python setup.py -e .[dev].

To run the tests run make test.

Code should be formatted with black.

Support

Open an issue.

License

The project is licensed under GPLv3.

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.6.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

inotify_lite-0.0.6-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file inotify_lite-0.0.6.tar.gz.

File metadata

  • Download URL: inotify_lite-0.0.6.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for inotify_lite-0.0.6.tar.gz
Algorithm Hash digest
SHA256 db043e2ed8b56773e91f7aebe8f1f1ee97fd7a4f3102ee6edaf50204267794f7
MD5 4266a43e9af3af23be8b081f09e7705c
BLAKE2b-256 d2c06993f806104f7321bbeb7839a6c250d17f47f84ce7151c0b1152ae88430a

See more details on using hashes here.

Provenance

File details

Details for the file inotify_lite-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: inotify_lite-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for inotify_lite-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e479dee4a7632c3e0e23f83a7c7673e773ec2d5f5796588d31aa4b87d62db2b0
MD5 5694e1e1aeaf4fa1a1fc0d08716f68f8
BLAKE2b-256 f81b21970c88ba73c7fc8a5ce5ec15aa0f27d44d2a7f52bd48d841e06cd4dbbe

See more details on using hashes here.

Provenance

Supported by

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