def run(self): indexer = IndexFiles() while self.runsignal: for folder in self.manager.get_followed(): if not self.wm.get_wd(folder): mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE | \ pyinotify.IN_MODIFY | pyinotify.IN_MOVED_TO | \ pyinotify.IN_MOVE_SELF | pyinotify.IN_MOVED_FROM self.wm.add_watch(folder, mask, rec=True) print 'Monitoring folder %s...' % folder try: data = self.queue.get(False) except: data = None if data: if data[0] == '+': indexer.index_files(add=[data[1]]) else: indexer.index_files(remove=[data[1]]) time.sleep(5)
from libs.indexmanager import FolderManager from index import IndexFiles if __name__ == "__main__": manager = FolderManager() indexer = IndexFiles() for followed in manager.get_followed(): print "Updating folder %s..." % followed indexer.index_folder(followed) print "Updated."