Skip to content

Commit

Permalink
Fix print error signals
Browse files Browse the repository at this point in the history
  • Loading branch information
rocodes committed Feb 6, 2024
1 parent ca3d754 commit fe2f5cb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions client/securedrop_client/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _on_export_process_error(self):
signature cannot change.
"""
self._cleanup_tmpdir()
err = self.process.readAllStandardError().data().decode("utf-8")
err = self.process.readAllStandardError().data().decode("utf-8").strip()

logger.error(f"Export process error: {err}")
self.export_state_changed.emit(ExportStatus.CALLED_PROCESS_ERROR)
Expand All @@ -212,29 +212,29 @@ def _on_print_preflight_success(self):
Print preflight success callback.
"""
self._cleanup_tmpdir()
err = self.process.readAllStandardError().data().decode("utf-8")
output = self.process.readAllStandardError().data().decode("utf-8").strip()
try:
status = ExportStatus(err)
status = ExportStatus(output)
self.print_preflight_check_succeeded.emit(status)
logger.debug("Print preflight success")

except ValueError as error:
logger.debug(f"Print preflight check failed: {error}")
logger.error("Print preflight check failed")
self.print_preflight_check_failed.emit(ExportStatus.ERROR_PRINT)
self.print_preflight_check_failed.emit(ExportError(ExportStatus.ERROR_PRINT))

def _on_print_prefight_error(self):
"""
Print Preflight error callback.
"""
self._cleanup_tmpdir()
err = self.process.readAllStandardError().data().decode("utf-8")
err = self.process.readAllStandardError().data().decode("utf-8").strip()
logger.debug(f"Print preflight error: {err}")
self.print_preflight_check_failed.emit(ExportStatus.ERROR_PRINT)
self.print_preflight_check_failed.emit(ExportError(ExportStatus.ERROR_PRINT))

# Todo: not sure if we need to connect here, since the print dialog is managed by sd-devices.
# We can probably use the export callback.
def _on_print_sucess(self):
def _on_print_success(self):
self._cleanup_tmpdir()
logger.debug("Print success")
self.print_succeeded.emit(ExportStatus.PRINT_SUCCESS)
Expand All @@ -259,7 +259,7 @@ def _on_print_error(self):
self._cleanup_tmpdir()
err = self.process.readAllStandardError()
logger.debug(f"Print error: {err}")
self.print_failed.emit(ExportStatus.ERROR_PRINT)
self.print_failed.emit(ExportError(ExportStatus.ERROR_PRINT))

def print(self, filepaths: List[str]) -> None:
"""
Expand All @@ -276,12 +276,12 @@ def print(self, filepaths: List[str]) -> None:
metadata=self._PRINT_METADATA,
filepaths=filepaths,
)
self._run_qrexec_export(archive_path, self._on_print_sucess, self._on_print_error)
self._run_qrexec_export(archive_path, self._on_print_success, self._on_print_error)

except IOError as e:
logger.error("Export failed")
logger.debug(f"Export failed: {e}")
self.print_failed.emit(e)
self.print_failed.emit(ExportError(ExportStatus.ERROR_PRINT))

self.export_completed.emit(filepaths)

Expand Down

0 comments on commit fe2f5cb

Please sign in to comment.