Module pyinotify :: Class SimpleINotify
[show private | hide private]
[frames | no frames]

Type SimpleINotify

object --+
         |
        SimpleINotify

Known Subclasses:
ThreadedINotify

Simple (non-threaded) INotify class, provides tools for watching files or directories, for reading notifications of events, and for processing these events.
Method Summary
  __init__(self)
initialization.
dict of str: int add_watch(self, path, mask, proc_fun, rec)
Add watch(es) on given path(s) with the specified mask and optionnally with a processing function.
  close(self)
Close the inotify's instance (close its file descriptor).
  event_check(self, timeout)
Check for inotify events
string or None get_path(self, wd)
Returns the path associated to WD, if WD doesn't exist or is inactive None is returned.
int or None get_wd(self, path)
Returns the watch descriptor associated to path, if path couldn't be retrieved or is inactive None is returned.
  process_events(self)
Process events from queue by calling their associated proccessing function (or functor).
  read_events(self)
Read events from device and enqueue them.
dict of int: bool rm_watch(self, wd, rec)
Removes watch(es).
dict of int: bool update_watch(self, wd, mask, proc_fun, rec)
Update existing watch(es).
  __add_watch(self, path, mask, proc_fun)
add a watch on path, stores the wd and the processing function, then returns the wd.
list of type(param) __format_param(self, param)
Return wrap param.
list of string or list of int __get_sub_rec(self, lpath)
Get every wd from self._wdd if its path is under the path of one (at least) of those in l.
string __walk_rec(self, top, rec)
Yields each subdirectories of top, doesn't follow symlinks.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__init__(self)
(Constructor)

initialization.
Overrides:
__builtin__.object.__init__

add_watch(self, path, mask, proc_fun=<pyinotify.ProcessEvent object at 0x40202fac>, rec=False)

Add watch(es) on given path(s) with the specified mask and optionnally with a processing function.
Parameters:
path - path to watch, the path can either be a file or a directory. Also accepts a sequence (list) of paths.
           (type=string or list of string)
mask - Bitmask of events.
           (type=int)
proc_fun - Optionnal processing function.
           (type=function or ProcessEvent instance or instance of one of its subclasses or callable object.)
rec - Recursively add watches from path on all its subdirectories, set to False by default (doesn't follows symlinks).
           (type=bool)
Returns:
dict of paths associated to watch descriptors. A wd value is positive if the watch has been sucessfully added, otherwise the value is negative.
           (type=dict of str: int)

close(self)

Close the inotify's instance (close its file descriptor). It destroys all existing watches, pending events,...

event_check(self, timeout=4)

Check for inotify events
Parameters:
timeout - The timeout is passed on to select.select(), thus timeout==0 means 'return immediately', timeout>0 means 'wait up to timeout seconds' and timeout==None means 'wait eternally', i.e. block.
           (type=int)

get_path(self, wd)

Returns the path associated to WD, if WD doesn't exist or is inactive None is returned.
Parameters:
wd - watch descriptor.
           (type=int)
Returns:
path or None.
           (type=string or None)

get_wd(self, path)

Returns the watch descriptor associated to path, if path couldn't be retrieved or is inactive None is returned.
Parameters:
path - pathname.
           (type=string)
Returns:
WD or None.
           (type=int or None)

process_events(self)

Process events from queue by calling their associated proccessing function (or functor).

read_events(self)

Read events from device and enqueue them.

rm_watch(self, wd, rec=False)

Removes watch(es).
Parameters:
wd - Watch descriptor of the file or directory to unwatch. Also accepts a list of WDs.
           (type=int or list of int.)
rec - Recursively removes watches on every already watched subdirectories and subfiles.
           (type=bool)
Returns:
dict of watch descriptors associated to booleans values. True if the corresponding wd has been successfully removed, False otherwise.
           (type=dict of int: bool)

update_watch(self, wd, mask=None, proc_fun=None, rec=False)

Update existing watch(es). Both the mask and the processing function can be modified.
Parameters:
wd - watch descriptor to update. Also accepts a list of watch descriptors.
           (type=int or list of int)
mask - Optional new bitmask of events.
           (type=int)
proc_fun - Optional new processing function.
           (type=function or ProcessEvent instance or instance of one of its subclasses or callable object.)
rec - Recursively update watches on every already watched subdirectories and subfiles.
           (type=bool)
Returns:
dict of watch descriptors associated to booleans values. True if the corresponding wd has been successfully updated, False otherwise.
           (type=dict of int: bool)

__add_watch(self, path, mask, proc_fun)

add a watch on path, stores the wd and the processing function, then returns the wd.

__format_param(self, param)

Parameters:
param - Parameter.
           (type=string or int)
Returns:
wrap param.
           (type=list of type(param))

__get_sub_rec(self, lpath)

Get every wd from self._wdd if its path is under the path of one (at least) of those in l. Doesn't follow symlinks.
Parameters:
lpath -
           (type=list of string or list of int)
Returns:

           (type=list of string or list of int)

__walk_rec(self, top, rec)

Yields each subdirectories of top, doesn't follow symlinks. If rec is false, only yield top.
Parameters:
top - root directory.
           (type=string)
rec - recursive flag.
           (type=bool)
Returns:
path of one subdirectory.
           (type=string)

Generated by Epydoc 2.1 on Wed Mar 29 03:46:07 2006 http://epydoc.sf.net