Skip to content

Commit

Permalink
(WIP) use parent update_content call in passphrase wizard. trim qrexe…
Browse files Browse the repository at this point in the history
…c output.
  • Loading branch information
rocodes committed Jan 31, 2024
1 parent c3f4f92 commit 5c99879
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
9 changes: 8 additions & 1 deletion client/securedrop_client/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand Down Expand Up @@ -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))

0 comments on commit 5c99879

Please sign in to comment.