Skip to content

Commit

Permalink
Use custom fswatch executable path
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-koch committed Nov 20, 2018
1 parent 2f33044 commit 26414f8
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions gitover/fswatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,22 @@ def __init__(self, path, parent=None):
self._path = path
self._tracked_paths = set()
self._buffer = bytes()
self.setProcessChannelMode(QProcess.ForwardedErrorChannel)
self.setWorkingDirectory(self._path)
cmd = "fswatch -0 -m fsevents_monitor ."
cmd = "\"{}\" -0 -m fsevents_monitor \"{}\"".format(self.executable(), self._path)
self.readyReadStandardError.connect(self._onStderr)
self.readyReadStandardOutput.connect(self._onStdout)
self.finished.connect(self._onFinished)
LOGGER.info("Starting fswatch for {}...".format(self._path))
self.start(cmd)
self.waitForStarted()
LOGGER.info("Started fswatch for {}".format(self._path))
LOGGER.info("Started fswatch PID={} for {}".format(self.processId(), self._path))
self._running = True

@pyqtSlot(int, QProcess.ExitStatus)
def _onFinished(self, exit_code, exit_status):
LOGGER.debug("fswatch terminated for {}: exitcode={} exitstatus={}"
.format(self._path, exit_code, exit_status))

@pyqtSlot()
def _stop(self):
LOGGER.debug("Term fswatch for {}...".format(self._path))
Expand Down Expand Up @@ -341,6 +347,15 @@ def _onStdout(self):
path, self._buffer = self._buffer.split(NUL, maxsplit=1)
paths.add(path.decode('utf-8'))
for path in paths:
LOGGER.debug("Check change for {} in {}".format(path, self._path))
if self.isTracked(path):
LOGGER.debug("Got change for {} in {}".format(path, self._path))
LOGGER.debug("Change of {} in {}".format(path, self._path))
self.pathChanged.emit(path)

@pyqtSlot()
def _onStderr(self):
"""Handle error output of `fswatch`."""
self._err_buffer += bytes(self.readAllStandardOutput())
while "\n" in self._err_buffer:
line, self._err_buffer = self._err_buffer.split("\n", maxsplit=1)
LOGGER.error(line)

0 comments on commit 26414f8

Please sign in to comment.