From bd1a243faa439a3be1328e5e0d9fefeb61d3d0c2 Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Sat, 23 Nov 2013 20:37:18 +0100 Subject: [PATCH] cleaned up main --- src/back/kite/filterdaemon.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/back/kite/filterdaemon.py b/src/back/kite/filterdaemon.py index b0686f2..9256d56 100644 --- a/src/back/kite/filterdaemon.py +++ b/src/back/kite/filterdaemon.py @@ -3,6 +3,8 @@ # import sys import pyinotify +import threads +from jsonfile import JsonFile wm = pyinotify.WatchManager() # Watch Manager mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE # watched events @@ -14,9 +16,16 @@ class EventHandler(pyinotify.ProcessEvent): def process_IN_DELETE(self, event): print "Removing:", event.pathname -handler = EventHandler() -notifier = pyinotify.Notifier(wm, handler) -wdd = wm.add_watch(sys.argv[1], mask, rec=True) -print "Watching %s" % sys.argv[1] +def init(path): + handler = EventHandler() + notifier = pyinotify.Notifier(wm, handler) + wdd = wm.add_watch(path, mask, rec=True) + threads_index = JsonFile(os.path.join(path, "threads_index.json")) + if threads_index.data == None: + threads_index.data = {} -notifier.loop() + + notifier.loop() + +if __name__ == "__main__": + init(sys.argv[1]) -- 2.43.0