def main(): opts = cmdline.parse() try: cfg = config.read_config(opts.config_file) except config.ConfigurationError as e: print("%s" % e) return 1 throttler = event_filters.throttler_factory(cfg.throttling) react = make_reporter(throttler=throttler, preprocessor=cfg.preprocessor) def callback(): runner.run(cfg.command, react) wm = pyinotify.WatchManager() handler = EventHandler( callback=callback, filter=event_filters.and_( event_filters.not_(event_filters.is_delete_dir_event), event_filters.simple_event_filter_factory(cfg.watch, cfg.global_ignore), throttler, ) ) notifier = pyinotify.Notifier(wm, handler) for watch in cfg.watch: wm.add_watch( watch.path, pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE, rec=watch.recurse, auto_add=watch.auto_add ) # force a test run on startup callback() notifier.loop()
def main(): opts = cmdline.parse() try: cfg = config.read_config(opts.config_file) except config.ConfigurationError as e: print("%s" % e) return 1 throttler = event_filters.throttler_factory(cfg.throttling) react = make_reporter(throttler=throttler, preprocessor=cfg.preprocessor) def callback(): runner.run(cfg.command, react) wm = pyinotify.WatchManager() handler = EventHandler( callback=callback, filter=event_filters.and_( event_filters.not_(event_filters.is_delete_dir_event), event_filters.simple_event_filter_factory(cfg.watch, cfg.global_ignore), throttler, )) notifier = pyinotify.Notifier(wm, handler) for watch in cfg.watch: wm.add_watch(watch.path, pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE, rec=watch.recurse, auto_add=watch.auto_add) # force a test run on startup callback() notifier.loop()
def test_and(self): f = and_(self.is_odd, self.is_big) self.assert_(f(1003)) self.failIf(f(1002)) self.failIf(f(3)) self.failIf(f(2))