module documentation
(source)

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 human​Readable​Mask 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 = (source)

Undocumented

Value
IN_CLOSE_WRITE|IN_CLOSE_NOWRITE
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
IN_OPEN: int = (source)

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