module documentation

This module provides support for Twisted to linux inotify API.

In order to use this support, simply do the following (and start a reactor at some point):

    from twisted.internet import inotify
    from twisted.python import filepath

    def notify(ignored, filepath, mask):
        """
        For historical reasons, an opaque handle is passed as first
        parameter. This object should never be used.

        @param filepath: FilePath on which the event happened.
        @param mask: inotify event as hexadecimal masks
        """
        print("event %s on %s" % (
            ', '.join(inotify.humanReadableMask(mask)), filepath))

    notifier = inotify.INotify()
    notifier.startReading()
    notifier.watch(filepath.FilePath("/some/directory"), callbacks=[notify])
    notifier.watch(filepath.FilePath(b"/some/directory2"), callbacks=[notify])

Note that in the above example, a FilePath which is a bytes path name or str path name may be used. However, no matter what type of FilePath is passed to this module, internally the FilePath is converted to bytes according to sys.getfilesystemencoding. For any FilePath returned by this module, the caller is responsible for converting from a bytes path name to a str path name.

Present Since
10.1
Class INotify The INotify file descriptor, it basically does everything related to INotify, from reading to notifying watch points.
Function humanReadableMask Auxiliary function that converts a hexadecimal mask into a series of human readable flags.
Constant IN_ACCESS Undocumented
Constant IN_ATTRIB Undocumented
Constant IN_CHANGED Undocumented
Constant IN_CLOSE Undocumented
Constant IN_CLOSE_NOWRITE Undocumented
Constant IN_CLOSE_WRITE Undocumented
Constant IN_CREATE Undocumented
Constant IN_DELETE Undocumented
Constant IN_DELETE_SELF Undocumented
Constant IN_DONT_FOLLOW Undocumented
Constant IN_IGNORED Undocumented
Constant IN_ISDIR Undocumented
Constant IN_MASK_ADD Undocumented
Constant IN_MODIFY Undocumented
Constant IN_MOVE_SELF Undocumented
Constant IN_MOVED Undocumented
Constant IN_MOVED_FROM Undocumented
Constant IN_MOVED_TO Undocumented
Constant IN_ONESHOT Undocumented
Constant IN_ONLYDIR Undocumented
Constant IN_OPEN Undocumented
Constant IN_Q_OVERFLOW Undocumented
Constant IN_UNMOUNT Undocumented
Constant IN_WATCH_MASK Undocumented
Class _Watch Watch object that represents a Watch point in the filesystem. The user should let INotify to create these objects
Constant _FLAG_TO_HUMAN Undocumented
def humanReadableMask(mask): (source)

Auxiliary function that converts a hexadecimal mask into a series of human readable flags.

IN_ACCESS: int = (source)

Undocumented

Value
1
IN_ATTRIB: int = (source)

Undocumented

Value
4
IN_CHANGED = (source)

Undocumented

Value
IN_MODIFY|IN_ATTRIB
IN_CLOSE_NOWRITE: int = (source)

Undocumented

Value
16
IN_CLOSE_WRITE: int = (source)

Undocumented

Value
8
IN_CREATE: int = (source)

Undocumented

Value
256
IN_DELETE: int = (source)

Undocumented

Value
512
IN_DELETE_SELF: int = (source)

Undocumented

Value
1024
IN_DONT_FOLLOW: int = (source)

Undocumented

Value
33554432
IN_IGNORED: int = (source)

Undocumented

Value
32768
IN_ISDIR: int = (source)

Undocumented

Value
1073741824
IN_MASK_ADD: int = (source)

Undocumented

Value
536870912
IN_MODIFY: int = (source)

Undocumented

Value
2
IN_MOVE_SELF: int = (source)

Undocumented

Value
2048
IN_MOVED = (source)

Undocumented

Value
IN_MOVED_FROM|IN_MOVED_TO
IN_MOVED_FROM: int = (source)

Undocumented

Value
64
IN_MOVED_TO: int = (source)

Undocumented

Value
128
IN_ONESHOT: int = (source)

Undocumented

Value
2147483648
IN_ONLYDIR: int = (source)

Undocumented

Value
16777216

Undocumented

Value
32
IN_Q_OVERFLOW: int = (source)

Undocumented

Value
16384
IN_UNMOUNT: int = (source)

Undocumented

Value
8192
_FLAG_TO_HUMAN = (source)

Undocumented

Value
[(IN_ACCESS, 'access'),
 (IN_MODIFY, 'modify'),
 (IN_ATTRIB, 'attrib'),
 (IN_CLOSE_WRITE, 'close_write'),
 (IN_CLOSE_NOWRITE, 'close_nowrite'),
 (IN_OPEN, 'open'),
 (IN_MOVED_FROM, 'moved_from'),
...