Skip to content

Commit

Permalink
docstrings for print and export callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
rocodes committed Feb 5, 2024
1 parent 3f9be9c commit 22a968e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions client/securedrop_client/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def _cleanup_tmpdir(self):

def _on_export_process_finished(self):
"""
Callback to handle and emit QProcess results. Method signature
cannot change.
Callback, handle and emit QProcess result. As with all such callbacks,
the method signature cannot change.
"""
self._cleanup_tmpdir()
# securedrop-export writes status to stderr
Expand All @@ -198,8 +198,8 @@ def _on_export_process_finished(self):

def _on_export_process_error(self):
"""
Callback, called if QProcess cannot complete. Method signature
cannot change.
Callback, called if QProcess cannot complete export. As with all such, the method
signature cannot change.
"""
self._cleanup_tmpdir()
err = self.process.readAllStandardError().data().decode("utf-8")
Expand All @@ -208,12 +208,18 @@ def _on_export_process_error(self):
self.export_state_changed.emit(ExportStatus.CALLED_PROCESS_ERROR)

def _on_print_preflight_success(self):
"""
Print preflight success callback.
"""
self._cleanup_tmpdir()

logger.debug("Print preflight success")
self.print_preflight_check_succeeded.emit()

def _on_print_prefight_error(self):
"""
Print Preflight error callback.
"""
self._cleanup_tmpdir()
logger.debug("Print preflight error")
self.print_preflight_check_failed.emit(ExportStatus.PRINT_PREFLIGHT_SUCCESS)
Expand All @@ -227,12 +233,20 @@ def _on_print_sucess(self):
self.export_completed.emit()

def end_process(self) -> None:
"""
Tell QProcess to quit if it hasn't already.
Connected to the ExportWizard's `finished` signal, which fires
when the dialog is closed, cancelled, or finished.
"""
self._cleanup_tmpdir()
logger.debug("Terminate process")
if self.process is not None and not self.process.waitForFinished(50):
self.process.terminate()

def _on_print_error(self):
"""
Error callback for print qrexec.
"""
self._cleanup_tmpdir()
err = self.process.readAllStandardError()
logger.debug(f"Print error: {err}")
Expand Down

0 comments on commit 22a968e

Please sign in to comment.