From: karim hamidou Date: Sat, 23 Nov 2013 19:37:18 +0000 (+0100) Subject: cleaned up main X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=bd1a243faa439a3be1328e5e0d9fefeb61d3d0c2;p=kite.git cleaned up main --- 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])