watcher
index
../watcher.py

This module manages the inotify watcher

 
Modules
       
createdb
gettext
logging.handlers
itertools
logging
os
pyinotify
time

 
Classes
       
__builtin__.object
InotifyDescriptor
NEvent
exceptions.Exception(exceptions.BaseException)
InotifyError

 
class InotifyDescriptor(__builtin__.object)
    This class represents all inotify watch descriptors created for
the current session: it tracks the task id and path related and gets
notifications of any new task created during the lifetime of the session
 
  Methods defined here:
__init__(self, SQLCon=None)
If SQLCon (as instance of createdb.SQLConnection) exists, use this
connection handler and ignore the one provided by this module
delete(self, tas_id=None, wd=None)
Delete a given task from inotify watcher. If tas_id is null,
wd must be a dict and the wds contained there will be erased from
the database
find(self)
Returns a list of dicts containing new path and action flag
These values cannot have a wd assigned (unless the task is
canceled)
insert(self, tas_id, tas_from)
A new task has been created so there's a new path to watch.
restart(self)
When required, this function returns a list of tasks that need to
backup a.s.a. there are changes. We need to reload the watch class
with all the tasks with the required information.
 
No input parameters. Returns a list containing dicts, each one
containing the to-backup path (Task.tas_from) and the task id
stop(self)
In case of need, user can make the watcher stop smoothly. This
method will update inotify_descriptor.ind_flag to STOP and the
daemon -as soon as it read it- will stop.
update(self, wd_dict)
Update descriptors that were assigned a wd.
Parameters:
    wd_dict: a dictionary containing 'path watched':['wd', [reserved],
    [task(s)]]

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
__table__ = 'inotify_descriptor'
delete_flag = 1
stop_flag = 0

 
class InotifyError(exceptions.Exception)
    A generic error class for Database Errors
 
 
Method resolution order:
InotifyError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8141680>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class NEvent(__builtin__.object)
    This class represents all generated events from the watcher
 
  Methods defined here:
__init__(self, id=None, **kwargs)
If id is not null, get the given NEvent from the database.
If kwargs is null, init an empty instance (must be fill later with db
data). kwargs must map to columns in event table. If key "eve_tas_id"
is missing or None from kwargs, it will be retrieved from the database.
If it does not exist in there, the init will fail
save(self)
Save the given instance in the database: only for new events

Static methods defined here:
pop(commit_=False, *min_max_eve)
Return the existing records in the database, deleting them from
table. This method will return a list of instances each of them
representing a NEvent.
Parameters:
commit: If True it will commit the transaction, False otherwise
min_max_eve: minimum and maximum event to retrieve and erase

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
__pk__ = 'eve_seq'
__table__ = 'event'
eve_seq = None
eve_tas_id = None

 
Data
        __all__ = ['InotifyDescriptor', 'InotifyError', 'NEvent']