summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-21 09:02:30 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-05-21 09:02:37 -0400
commitd78e0cc91947a06ae7687cb54f805787fb00d28f (patch)
tree2555001e52cada4f0dd3bb68163b178874eacddd /src/lib/Bcfg2/Server/FileMonitor/Inotify.py
parent661c5db322987b14178568325c71957451a3306e (diff)
downloadbcfg2-d78e0cc91947a06ae7687cb54f805787fb00d28f.tar.gz
bcfg2-d78e0cc91947a06ae7687cb54f805787fb00d28f.tar.bz2
bcfg2-d78e0cc91947a06ae7687cb54f805787fb00d28f.zip
fixed bug in pseudo fm, deduplicated code
Diffstat (limited to 'src/lib/Bcfg2/Server/FileMonitor/Inotify.py')
-rw-r--r--src/lib/Bcfg2/Server/FileMonitor/Inotify.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lib/Bcfg2/Server/FileMonitor/Inotify.py b/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
index 9743d868d..b87e10bd0 100644
--- a/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
+++ b/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
@@ -5,7 +5,8 @@ import stat
import logging
import operator
import pyinotify
-from Bcfg2.Server.FileMonitor import FileMonitor, Event
+from Bcfg2.Server.FileMonitor import Event
+from Bcfg2.Server.FileMonitor.Pseudo import Pseudo
logger = logging.getLogger(__name__)
@@ -20,12 +21,12 @@ class InotifyEvent(Event):
self.action = self.action_map[event.mask]
-class Inotify(FileMonitor, pyinotify.ProcessEvent):
+class Inotify(Pseudo, pyinotify.ProcessEvent):
__priority__ = 1
mask = pyinotify.IN_CREATE | pyinotify.IN_DELETE | pyinotify.IN_MODIFY
def __init__(self, ignore=None, debug=False):
- FileMonitor.__init__(self, ignore=ignore, debug=debug)
+ Pseudo.__init__(self, ignore=ignore, debug=debug)
self.wm = pyinotify.WatchManager()
self.notifier = pyinotify.ThreadedNotifier(self.wm, self)
self.notifier.start()
@@ -47,14 +48,10 @@ class Inotify(FileMonitor, pyinotify.ProcessEvent):
wd = watch.wd
else:
wd = res[path]
- self.handles[wd] = obj
- self.events.append(Event(wd, path, "exists"))
-
- mode = os.stat(path)[stat.ST_MODE]
- if stat.S_ISDIR(mode):
- for wname in os.listdir(path):
- self.events.append(Event(wd, wname, "exists"))
- return wd
+
+ # inotify doesn't produce initial 'exists' events, so we
+ # inherit from Pseudo to produce those
+ return Pseudo.AddMonitor(self, path, obj, handleID=wd)
def shutdown(self):
self.notifier.stop()