Renamed Notifier and Watch Manager to start with __ prefix

pull/25/head
Lee Clemens 2011-12-31 03:37:43 -05:00
parent 4c13063498
commit 5c4ec6e7fb
1 changed files with 11 additions and 11 deletions

View File

@ -52,7 +52,7 @@ class FilterPyinotify(FileFilter):
FileFilter.__init__(self, jail) FileFilter.__init__(self, jail)
self.__modified = False self.__modified = False
# Pyinotify watch manager # Pyinotify watch manager
self.monitor = pyinotify.WatchManager() self.__monitor = pyinotify.WatchManager()
logSys.debug("Created FilterPyinotify") logSys.debug("Created FilterPyinotify")
self.__watches = dict() self.__watches = dict()
@ -77,7 +77,7 @@ class FilterPyinotify(FileFilter):
if self.containsLogPath(path): if self.containsLogPath(path):
logSys.error(path + " already exists") logSys.error(path + " already exists")
else: else:
wd = self.monitor.add_watch(path, pyinotify.IN_MODIFY) wd = self.__monitor.add_watch(path, pyinotify.IN_MODIFY)
self.__watches.update(wd) self.__watches.update(wd)
FileFilter.addLogPath(self, path, tail) FileFilter.addLogPath(self, path, tail)
logSys.info("Added logfile = %s" % path) logSys.info("Added logfile = %s" % path)
@ -92,7 +92,7 @@ class FilterPyinotify(FileFilter):
logSys.error(path + " is not monitored") logSys.error(path + " is not monitored")
else: else:
wdInt = self.__watches[path] wdInt = self.__watches[path]
wd = self.monitor.rm_watch(wdInt) wd = self.__monitor.rm_watch(wdInt)
if wd[wdInt]: if wd[wdInt]:
del self.__watches[path] del self.__watches[path]
FileFilter.delLogPath(self, path) FileFilter.delLogPath(self, path)
@ -109,14 +109,14 @@ class FilterPyinotify(FileFilter):
def run(self): def run(self):
self.setActive(True) self.setActive(True)
self.notifier = pyinotify.ThreadedNotifier(self.monitor, self.__notifier = pyinotify.ThreadedNotifier(self.__monitor,
ProcessPyinotify(self)) ProcessPyinotify(self))
self.notifier.start() self.__notifier.start()
while self._isActive(): while self._isActive():
if not self.getIdle(): if not self.getIdle():
self.notifier.process_events() self.__notifier.process_events()
if self.notifier.check_events(): if self.__notifier.check_events():
self.notifier.read_events() self.__notifier.read_events()
else: else:
time.sleep(self.getSleepTime()) time.sleep(self.getSleepTime())
# Cleanup pyinotify # Cleanup pyinotify
@ -131,14 +131,14 @@ class FilterPyinotify(FileFilter):
# Call super to set __isRunning # Call super to set __isRunning
super(FilterPyinotify, self).stop() super(FilterPyinotify, self).stop()
# Now stop the Notifier, otherwise we're deadlocked # Now stop the Notifier, otherwise we're deadlocked
self.notifier.stop() self.__notifier.stop()
## ##
# Deallocates the resources used by pyinotify. # Deallocates the resources used by pyinotify.
def __cleanup(self): def __cleanup(self):
del self.notifier del self.__notifier
del self.monitor del self.__monitor
class ProcessPyinotify(pyinotify.ProcessEvent): class ProcessPyinotify(pyinotify.ProcessEvent):