コード例 #1
0
    def run(self):
        watches = {}
        observer = self.observer_class()
        observer.start()

        while not self.should_reload:
            to_delete = set(watches)
            paths = _find_observable_paths(self.extra_files)
            for path in paths:
                if path not in watches:
                    try:
                        watches[path] = observer.schedule(
                            self.event_handler, path, recursive=False
                        )  # FIX: docker-compose performance issue
                    except OSError:
                        # "Path is not a directory". We could filter out
                        # those paths beforehand, but that would cause
                        # additional stat calls.
                        watches[path] = None
                to_delete.discard(path)
            for path in to_delete:
                watch = watches.pop(path, None)
                if watch is not None:
                    observer.unschedule(watch)
            self.observable_paths = paths
            self._sleep(self.interval)

        sys.exit(3)
コード例 #2
0
ファイル: __init__.py プロジェクト: baylee-d/osf.io
    def run(self):
        watches = {}
        observer = self.observer_class()
        observer.start()

        while not self.should_reload:
            to_delete = set(watches)
            paths = _find_observable_paths(self.extra_files)
            for path in paths:
                if path not in watches:
                    try:
                        watches[path] = observer.schedule(
                            self.event_handler, path, recursive=False)  # FIX: docker-compose performance issue
                    except OSError:
                        # "Path is not a directory". We could filter out
                        # those paths beforehand, but that would cause
                        # additional stat calls.
                        watches[path] = None
                to_delete.discard(path)
            for path in to_delete:
                watch = watches.pop(path, None)
                if watch is not None:
                    observer.unschedule(watch)
            self.observable_paths = paths
            self._sleep(self.interval)

        sys.exit(3)
コード例 #3
0
    def run(self):
        watches = {}
        observer = self.observer_class()
        observer.start()

        to_delete = set(watches)
        paths = _find_observable_paths(self.extra_files)
        for path in paths:
            if path not in watches:
                try:
                    watches[path] = observer.schedule(
                        self.event_handler, path, recursive=True)
                except OSError as e:
                    message = str(e)

                    if message != "Path is not a directory":
                        # Log the exception
                        _log('error', message)

                    # Clear this path from list of watches We don't want
                    # the same error message showing again in the next
                    # iteration.
                    watches[path] = None
            to_delete.discard(path)
        for path in to_delete:
            watch = watches.pop(path, None)
            if watch is not None:
                observer.unschedule(watch)
        self.observable_paths = paths

        yield from self.should_reload.wait()

        sys.exit(3)
コード例 #4
0
    def run(self):
        watches = {}
        observer = self.observer_class()
        observer.start()

        to_delete = set(watches)
        paths = _find_observable_paths(self.extra_files)
        for path in paths:
            if path not in watches:
                try:
                    watches[path] = observer.schedule(self.event_handler,
                                                      path,
                                                      recursive=True)
                except OSError as e:
                    message = str(e)

                    if message != "Path is not a directory":
                        # Log the exception
                        _log('error', message)

                    # Clear this path from list of watches We don't want
                    # the same error message showing again in the next
                    # iteration.
                    watches[path] = None
            to_delete.discard(path)
        for path in to_delete:
            watch = watches.pop(path, None)
            if watch is not None:
                observer.unschedule(watch)
        self.observable_paths = paths

        yield from self.should_reload.wait()

        sys.exit(3)
コード例 #5
0
ファイル: watchman.py プロジェクト: dwakna/indico-cbnu
 def run(self):
     self._client = pywatchman.client(timeout=300)
     self._client.capabilityCheck(
         required=['wildmatch', 'cmd-watch-project'])
     indico_project_root = os.path.realpath(
         os.path.join(get_root_path('indico'), '..'))
     paths = sorted({
         os.path.realpath(p)
         for p in _find_observable_paths() if os.path.exists(p)
     })
     for path in paths:
         patterns = ['**/*.py', '**/entry_points.txt']
         if path == indico_project_root:
             patterns += ['indico/indico.conf', 'indico/logging.yaml']
         watcher = Watcher(path, patterns)
         watcher.start(self._client)
         self._watchers.add(watcher)
     self._launch()
     self._monitor()