From c5bc6a85d2011beeea43d507543ef0e68ef9f8bd Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 23 Jul 2012 10:15:28 -0400 Subject: [PATCH] cc-4105: added support for multiple watched directories --- python_apps/media-monitor2/media/monitor/bootstrap.py | 1 - python_apps/media-monitor2/mm2.py | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/bootstrap.py b/python_apps/media-monitor2/media/monitor/bootstrap.py index 25aa2c133..1272897cd 100644 --- a/python_apps/media-monitor2/media/monitor/bootstrap.py +++ b/python_apps/media-monitor2/media/monitor/bootstrap.py @@ -65,7 +65,6 @@ class Bootstrapper(Loggable): deleted += 1 else: self.logger.error("Could not find the signal corresponding to path: '%s'" % watch_dir) - self.logger.info( "Flushed watch directories. (modified, deleted) = (%d, %d)" % (modded, deleted) ) diff --git a/python_apps/media-monitor2/mm2.py b/python_apps/media-monitor2/mm2.py index 45d83993e..fc2a020fe 100644 --- a/python_apps/media-monitor2/mm2.py +++ b/python_apps/media-monitor2/mm2.py @@ -28,7 +28,7 @@ log = get_logger() apiclient = apc.AirtimeApiClient(log) # We initialize sdb before anything because we must know what our watched # directories are. -sdb = SyncDB(apc) +sdb = SyncDB(apiclient) for watch_dir in sdb.list_directories(): if not os.path.exists(watch_dir): # Create the watch_directory here @@ -40,12 +40,10 @@ for watch_dir in sdb.list_directories(): if os.path.exists(watch_dir): channels['watch'].append(PathChannel('watch', watch_dir)) -org = Organizer(channel=channels['org'],target_path=channels['watch'].path) +org = Organizer(channel=channels['org'],target_path=channels['watch'][0].path) watches = [ WatchSyncer(channel=pc) for pc in channels['watch'] ] problem_files = ProblemFileHandler(channel=channels['badfile']) -raw_bootstrap = apiclient.get_bootstrap_info() -print(raw_bootstrap) # A slight incosistency here, channels['watch'] is already a list while the # other items are single elements. For consistency we should make all the # values in channels lists later on @@ -68,7 +66,8 @@ wm = pyinotify.WatchManager() # Listeners don't care about which directory they're related to. All they care # about is which signal they should respond to o1 = OrganizeListener(signal=channels['org'].signal) -o2 = StoreWatchListener(signal=channels['watch'].signal) +# We are assuming that the signals are the same for each watched directory here +o2 = StoreWatchListener(signal=channels['watch'][0].signal) notifier = pyinotify.Notifier(wm) wdd1 = wm.add_watch(channels['org'].path, pyinotify.ALL_EVENTS, rec=True, auto_add=True, proc_fun=o1)