From 5c9987969e06079fb378d50ae02f20aefbe66a3d Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 31 Jan 2024 09:41:22 -0500 Subject: [PATCH] (WIP) use parent update_content call in passphrase wizard. trim qrexec output. --- client/securedrop_client/export.py | 9 +++++++- .../conversation/export/export_wizard_page.py | 22 +++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/client/securedrop_client/export.py b/client/securedrop_client/export.py index 5b189b59dd..b18be2a68e 100644 --- a/client/securedrop_client/export.py +++ b/client/securedrop_client/export.py @@ -209,8 +209,15 @@ def _run_qrexec_export(self, archive_path: str) -> ExportStatus: stderr=subprocess.STDOUT, ) result = output.decode("utf-8").strip() + if result: - return ExportStatus(result) + # This is a bit messy, but make sure we are just taking the last line + # (no-op if no newline) + status_string = result.split("\n")[-1] + return ExportStatus(status_string) + else: + logger.error("Export subprocess did not return a value we could parse") + raise ExportError(ExportStatus.UNEXPECTED_RETURN_STATUS) except ValueError as e: logger.debug(f"Export subprocess returned unexpected value: {e}") diff --git a/client/securedrop_client/gui/conversation/export/export_wizard_page.py b/client/securedrop_client/gui/conversation/export/export_wizard_page.py index 2375ce76d9..4729395f20 100644 --- a/client/securedrop_client/gui/conversation/export/export_wizard_page.py +++ b/client/securedrop_client/gui/conversation/export/export_wizard_page.py @@ -200,7 +200,7 @@ def on_status_received(self, status: ExportStatus) -> None: def update_content(self, status: ExportStatus) -> None: """ Update page's content based on new status. - Children can re-implement this method. + Children may re-implement this method. """ if not status: logger.error("Empty status value given to update_content") @@ -210,7 +210,7 @@ def update_content(self, status: ExportStatus) -> None: self.error_details.setText(STATUS_MESSAGES.get(status)) self.error_details.show() else: - self.body.setText(STATUS_MESSAGES.get(status)) + self.error_details.hide() class PreflightPage(ExportWizardPage): @@ -391,13 +391,13 @@ def on_status_received(self, status: ExportStatus) -> None: super().on_status_received(status) self.update_content(status) - def update_content(self, status: ExportStatus) -> None: - if not status: - logger.error("Empty status value given to update_content") - status = ExportStatus.UNEXPECTED_RETURN_STATUS + # def update_content(self, status: ExportStatus) -> None: + # if not status: + # logger.error("Empty status value given to update_content") + # status = ExportStatus.UNEXPECTED_RETURN_STATUS - if status in super().ERROR_HINT_MESSAGE: - self.error_details.setText(STATUS_MESSAGES.get(status)) - self.error_details.show() - else: - self.body.setText(STATUS_MESSAGES.get(status)) + # if status in super().ERROR_HINT_MESSAGE: + # self.error_details.setText(STATUS_MESSAGES.get(status)) + # self.error_details.show() + # else: + # self.body.setText(STATUS_MESSAGES.get(status))