def scan_folder(folder): apps_info = apps.load_all_apps() config = apps.load_app_config() wm = WatchManager2() handler = EventHandler(wm, apps_info, config) for element, isdir in walk_folder(folder): handler.send_repeated_creation(element, isdir)
def start_watching(folder): apps_info = apps.load_all_apps() config = apps.load_app_config() wm = WatchManager2() handler = EventHandler(wm, config, apps_info, folder) notifier = pyinotify.Notifier(wm, handler, timeout=10) gobject.timeout_add(100, quick_check, notifier) # Exclude files beginning with . or ending in ~ e_filter = pyinotify.ExcludeFilter(['((/[^/]+)*/\\..*)|((/[^/]+)*/.+~)']) wm.add_watch(folder, handler.mask(), rec=True, auto_add=True, exclude_filter=e_filter) print "Starting to watch..."