class WatchManager(watchdir): path = os.path.abspath(watchdir) #path = list() ##(str or list of str): ## Path(s) to watch, the path can either be a file or a directory. add_watch(path, mask, proc_fun=None, rec=False, auto_add=False) = dict() #=> dict mask(int) = int(mask) #Bitmask of events. proc_func(ProcessEvent) = proc_func ### Processing object (must be callable). Will be called if provided, otherwise, notifier.default_proc_funcwill be called. rec(bool) = bool(rec) ###### Recursively add watches on the given path and on all its subdirectories. auto_add(bool) = bool(auto_add) # Automatically add watches on newly created directories in the watch's path. update_watch(wd, mask=None, proc_func=None, rec=False, auto_add=False) = update_watch #=> dict #Update existing watch(s). All these parameters are updatable. rm_watch(wd, rec=False) = dict() #=> dict #Remove watch(s). get_wd(path) #=> int #Return the watch descriptor associated to path. get_path(wd) #=> str #Return the path associated to wd, if wd is invalid, None is returned. return os.path.abspath(wd) ra = notifier.add_watch('/a-dir', mask) if ra['/a-dir'] > 0: print "added" #update_watch wd (or list of wds) {wd1: success, wd2: success, ...} #Where success is True if the op on wdx succeeded, False otherwise. ru = notifier.update_watch(ra['/a-dir'], new_mask) if ru['/a-dir']: print "updated" #rm_watch wd (or list of wds) {wd1: success, wd2: success, ...} #Where success is True if the op on wdx succeeded, False otherwise. rr = notifier.rm_watch(ra['/a-dir']) if rr['/a-dir']: print "deleted"