def RemoveWatchDirectory(self, dpath): """Remove a directory from the watch @param dpath: directory path to remove (unicode) """ dobj = fileutil.Directory(dpath) with self._lock: if dobj in self._dirs: self._dirs.remove(dobj)
def AddWatchDirectory(self, dpath): """Add a directory to the watch list @param dpath: directory path (unicode) """ assert os.path.isdir(dpath) dobj = fileutil.Directory(dpath) with self._lock: if dobj not in self._dirs: # Get current snapshot of the directory dobj = fileutil.GetDirectoryObject(dpath, False, True) self._dirs.append(dobj)
def RemoveWatchDirectory(self, dpath): """Remove a directory from the watch @param dpath: directory path to remove (unicode) """ dobj = fileutil.Directory(dpath) self._changePending = True with self._lock: if dobj in self._dirs: self._dirs.remove(dobj) # Also remove any subpaths of dpath toremove = list() for d in self._dirs: if fileutil.IsSubPath(d.Path, dpath): toremove.append(d) for todel in toremove: self._dirs.remove(todel) self._changePending = False
def AddWatchDirectory(self, dpath): """Add a directory to the watch list @param dpath: directory path (unicode) @return: bool - True means watch was added, False means unable to list directory """ assert os.path.isdir(dpath) dobj = fileutil.Directory(dpath) self._changePending = True with self._lock: if dobj not in self._dirs and os.access(dobj.Path, os.R_OK): # Get current snapshot of the directory try: dobj = fileutil.GetDirectoryObject(dpath, False, True) except OSError: self._changePending = False return False self._dirs.append(dobj) with self._listEmptyCond: self._listEmptyCond.notify() self._changePending = False return True