Example #1
0
    def unwatch(self, path, parent):
        """Handles unwatch commands.

        A process that wishes to stop watching a directory will issue an
        unwatch command. This method removes the watch if necessary."""
        self._logger.info("Unwatch command ran for {} by {}".format(path, parent))

        try:
            watch_manager = WatchManager(self._task_runner, self._file_watcher)
        except IOError as e:
            self._logger.error("I/O error({0}): {1}".format(e.errno, e.strerror))
            return os.EX_IOERR
        except cPickle.UnpicklingError as e:
            return OS.EX_IOERR

        try:
            watch_manager.remove(parent, path)
        except OSError as e:
            self._logger.error(e)
            return os.EX_UNAVAILABLE
        except WatchManagerError as e:
            return os.EX_IOERR
Example #2
0
    def watch(self, path, parent):
        """Handles watch commands.

        A process that wishes to set up watches for a directory will issue a
        watch command. This sets up the watch if necessary."""
        self._logger.info("Watch command ran for {} by {}".format(path, parent))

        project_config = self._config.get_config_for_path(os.getcwd())

        try:
            watch_manager = WatchManager(self._task_runner, self._file_watcher)
        except IOError as e:
            self._logger.error("I/O error({0}): {1}".format(e.errno, e.strerror))
            return os.EX_IOERR
        except cPickle.UnpicklingError as e:
            return OS.EX_IOERR

        try:
            watch_manager.add(parent, path)
        except OSError as e:
            self._logger.error(e)
            return os.EX_UNAVAILABLE
        except WatchManagerError as e:
            return os.EX_IOERR