本文整理汇总了Python中watchdog.events.PatternMatchingEventHandler方法的典型用法代码示例。如果您正苦于以下问题:Python events.PatternMatchingEventHandler方法的具体用法?Python events.PatternMatchingEventHandler怎么用?Python events.PatternMatchingEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类watchdog.events
的用法示例。
在下文中一共展示了events.PatternMatchingEventHandler方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from watchdog import events [as 别名]
# 或者: from watchdog.events import PatternMatchingEventHandler [as 别名]
def __init__(self, runner):
self.runner = runner
self.event_handler = PatternMatchingEventHandler(patterns=["*.fast5"],
ignore_patterns=[],
ignore_directories=True)
self.event_handler.on_created = self.on_created
self.event_handler.on_moved = self.on_moved
self.observer = Observer()
self.observedPaths = []
for path in self.runner.input:
if os.path.isdir(path):
self.observer.schedule(self.event_handler, path, recursive=True)
self.observedPaths.append(path)
log("Monitoring {} in real time. Press Ctrl+C to exit.".format(", ".join(self.observedPaths)))
示例2: __init__
# 需要导入模块: from watchdog import events [as 别名]
# 或者: from watchdog.events import PatternMatchingEventHandler [as 别名]
def __init__(self, media):
self._media = media
self.event_handler = PatternMatchingEventHandler(
patterns=_storage.extensions)
self.event_handler.on_created = self.on_created
self.event_handler.on_moved = self.on_moved
self.event_handler.on_deleted = self.on_deleted
self.observer = Observer()
self.observer.schedule(self.event_handler, self._media.folder,
recursive=True)
self.observer.start()
示例3: make_handler
# 需要导入模块: from watchdog import events [as 别名]
# 或者: from watchdog.events import PatternMatchingEventHandler [as 别名]
def make_handler(file_name):
class Handler(PatternMatchingEventHandler):
def on_modified(self, event):
log.debug('Modified: {}'.format(event.src_path))
with open(file_name) as f:
code = f.read()
code_atom.reset(code)
return Handler(patterns=[abspath(file_name)])
示例4: __init__
# 需要导入模块: from watchdog import events [as 别名]
# 或者: from watchdog.events import PatternMatchingEventHandler [as 别名]
def __init__(self, folder, callback, dbpool):
print 'now scanning {0}'.format(folder)
self.path = folder
self.callback = callback
self.dbpool = dbpool
self.event_handler = PatternMatchingEventHandler(patterns=['*'])
self.event_handler.process = self.process
self.event_handler.on_any_event = self.on_any_event
self.observer = Observer()
self.observer.schedule(self.event_handler, self.path, recursive=True)
self.observer.start()
示例5: __init__
# 需要导入模块: from watchdog import events [as 别名]
# 或者: from watchdog.events import PatternMatchingEventHandler [as 别名]
def __init__(self, container, host_dir, container_dir, options=None):
"""
Initialize a new instance of ContainerNotifier
Args:
container: Container
host_dir (str): Host directory
container_dir (str): Container directory
"""
self.container = container
self.host_dir = host_dir
self.container_dir = container_dir
options = NotifierOptions() if options is None else options
event_handler = PatternMatchingEventHandler(
ignore_patterns=options.exclude_patterns, ignore_directories=False)
handler = self.__change_handler
event_handler.on_created = handler
event_handler.on_moved = handler
event_handler.on_modified = handler
if options.notify_debounce:
logging.info('File change events debouncing with %fs delay.', options.notify_debounce)
self.notify_debounced = CallDebouncer(self.notify, options.notify_debounce)
else:
self.notify_debounced = self.notify
self.observer = Observer()
self.observer.schedule(event_handler, host_dir, recursive=True)
self.observer.start()
示例6: observe_trig_file
# 需要导入模块: from watchdog import events [as 别名]
# 或者: from watchdog.events import PatternMatchingEventHandler [as 别名]
def observe_trig_file():
print_limit(" - Enabling Trigger Events Config File Observation -", 2)
path = homedir + "/Pigrow/config/"
trig_events_handler = PatternMatchingEventHandler("*.txt", "", True, False)
trig_events_handler.on_created = trig_change
trig_events_handler.on_modified = trig_change
trig_events_ob = Observer()
trig_events_ob.schedule(trig_events_handler, path, recursive=True)
trig_events_ob.start()