Skip to main content

Recursive inotify watches based on inotify_simple.

Project description

Inotify Recursive - Recursive inotify watches for Python

Inotify Recursive is a Python package that offers a simple way to watch a directory-tree recursively for file changes via the inotify functionality of the Linux kernel. It uses the inotify_simple package to set and remove the inotify watches and also incorporates its whole functionality. The package is written in Python and licensed as open-source under the GPL version 3.

At the moment the main purpose of Inotify Recursive is to provide the file watching functionality for Synoindex Watcher, a small tool that automatically updates the media index of Synology DiskStations.

This Python package is still an alpha! Its core functionality has been tested and is working, but there could still be undiscovered bugs. Also breaking interface changes are likely to happen, so it is not recommended to use it in production projects, yet.

Features

  • Small Less than 150 lines of code (including comments)
  • Powerfull All features of inotify-simple plus recursive watching
  • Agnostic Python 2 and Python 3 compatible (minimum tested version is 2.7)

Installation

The recommended installation method is via pip:

pip install inotifyrecursive

You could also simply clone the repository or copy the code directly into your project, but don't forget to install the dependencies inotify-simple and enum (Python2 only), if you choose one of these ways.

Documentation

Please read the docs for inotify_simple first, since the basic usage is the same.

The INotify class of Inotify Recursive provides three additional methods, which are useful, if a directory shall be watched recursively:

inotify.add_watch_recursive(path, mask, filter = None)

  • path The path to watch
  • mask The mask of events to watch for
  • filter A function to ignore certain sub-directories

Returns the descriptor for the newly created watch of the directory where the given path points to. Unlike add_watch() this function also creates watches for all sub-directories below it. The descriptors of the sub-watches are not returned.

The filter function is optional. If it exists it takes a directory-name and returns boolean value which describes whether the directory shall be watched (True) or ignored (False).

inotify.rm_watch_recursive(wd)

  • wd The watch descriptor to remove

Removes the watch with the given descriptor and all associated sub-watches. Should be used for any watch that has been created by add_watch_recursive().

inotify.get_path(wd)

  • wd The watch descriptor the path is fetched for

Returns the absolute path of the directory associated to the watch with given descriptor.


Copyright 2019 Torben Haase <https://pixelsvsbytes.com>

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

inotifyrecursive-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

inotifyrecursive-0.1.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file inotifyrecursive-0.1.0.tar.gz.

File metadata

  • Download URL: inotifyrecursive-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for inotifyrecursive-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ccd5836d85a4f85627eb9a42a703bf2f05e88f642cee633765dc77f859c3e69a
MD5 dca32c569005ffc803ebbb009320b3e6
BLAKE2b-256 693d6247350657f878667131951065f11485cb4aacf9d2e8f8464758d2e19515

See more details on using hashes here.

File details

Details for the file inotifyrecursive-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: inotifyrecursive-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for inotifyrecursive-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 387fb9bd60222d94a1a6bea1722ced1d0a792b6703bdab658db41164926675f9
MD5 b729663fe59112806ff9696779ddad6b
BLAKE2b-256 bad059ef4fcf9be4c94b12cec189945969146a3cdcf3cc2b0cac24fa53071789

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