Exemplo n.º 1
0
 def _process_pipe(self) -> None:
     """Open paths from stdout."""
     _logger.debug("Opening paths from '%s'...", self.program())
     stdout = qbytearray_to_str(self.readAllStandardOutput())
     try:
         api.open_paths(path for path in stdout.split("\n") if os.path.exists(path))
         _logger.debug("... opened paths from pipe")
         api.status.update("opened paths from pipe")
     except api.commands.CommandError:
         log.warning("%s: No paths from pipe", self.program())
Exemplo n.º 2
0
 def _on_finished(self, exitcode, exitstatus):
     """Check exit status and possibly process standard output on completion."""
     if exitstatus != QProcess.NormalExit or exitcode != 0:
         log.error(
             "Error running external process '%s':\n%s",
             self.program(),
             qbytearray_to_str(self.readAllStandardError()).strip(),
         )
     elif self._pipe:
         self._process_pipe()
     else:
         _logger.debug("Finished external process '%s' succesfully", self.program())
def test_qbytearray_to_str():
    text = "text"
    qbytearray = QByteArray(text.encode())
    assert utils.qbytearray_to_str(qbytearray) == text