Python watchdog.events.PatternMatchingEventHandler() Examples

The following are 6 code examples of watchdog.events.PatternMatchingEventHandler(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module watchdog.events , or try the search function .
Example #1
Source File: watcher.py    From pineal with GNU Affero General Public License v3.0 6 votes vote down vote up
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)]) 
Example #2
Source File: realtime.py    From picopore with GNU General Public License v3.0 6 votes vote down vote up
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))) 
Example #3
Source File: folder.py    From ffplayout-engine with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #4
Source File: watching.py    From iWant with MIT License 5 votes vote down vote up
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() 
Example #5
Source File: container_notifier.py    From docker-windows-volume-watcher with MIT License 5 votes vote down vote up
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() 
Example #6
Source File: trigger_watcher.py    From Pigrow with GNU General Public License v3.0 5 votes vote down vote up
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()