mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Make tasks more robust in handling failure by checking for return codes
This commit is contained in:
parent
3928a3fa5a
commit
90df7894aa
3 changed files with 17 additions and 6 deletions
|
@ -46,7 +46,7 @@ class TaskBase(QtCore.QThread):
|
||||||
output += p.stdout.read()
|
output += p.stdout.read()
|
||||||
self.update_details.emit(output)
|
self.update_details.emit(output)
|
||||||
|
|
||||||
return output
|
return p.returncode, output
|
||||||
|
|
||||||
|
|
||||||
class PullImageTask(TaskBase):
|
class PullImageTask(TaskBase):
|
||||||
|
@ -98,7 +98,11 @@ class ConvertToPixels(TaskBase):
|
||||||
"dangerzone",
|
"dangerzone",
|
||||||
"document-to-pixels",
|
"document-to-pixels",
|
||||||
]
|
]
|
||||||
output = self.exec_container(args)
|
returncode, output = self.exec_container(args)
|
||||||
|
|
||||||
|
if returncode != 0:
|
||||||
|
self.task_failed.emit(f"Return code: {returncode}")
|
||||||
|
return
|
||||||
|
|
||||||
# Did we hit an error?
|
# Did we hit an error?
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
|
@ -197,5 +201,11 @@ class ConvertToPDF(TaskBase):
|
||||||
+ envs
|
+ envs
|
||||||
+ ["dangerzone", "pixels-to-pdf",]
|
+ ["dangerzone", "pixels-to-pdf",]
|
||||||
)
|
)
|
||||||
self.exec_container(args)
|
returncode, output = self.exec_container(args)
|
||||||
|
|
||||||
|
if returncode != 0:
|
||||||
|
self.task_failed.emit(f"Return code: {returncode}")
|
||||||
|
return
|
||||||
|
|
||||||
self.task_finished.emit()
|
self.task_finished.emit()
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,11 @@ class TasksWidget(QtWidgets.QWidget):
|
||||||
self.task_details.setText(s)
|
self.task_details.setText(s)
|
||||||
|
|
||||||
def task_failed(self, err):
|
def task_failed(self, err):
|
||||||
self.task_label.setText("Task failed :(")
|
self.task_label.setText("Failed :(")
|
||||||
self.task_details.setWordWrap(True)
|
self.task_details.setWordWrap(True)
|
||||||
|
text = self.task_details.text()
|
||||||
self.task_details.setText(
|
self.task_details.setText(
|
||||||
f"Directory with pixel data: {self.common.pixel_dir.name}\n\n{err}"
|
f"{text}\n\n--\n\nDirectory with pixel data: {self.common.pixel_dir.name}\n\n{err}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def all_done(self):
|
def all_done(self):
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c0cc2c3e7e168bbf6a9bc39c582039d0fbad52bb
|
Subproject commit 86599101444c476d2c53a97232e8c6bcbecadc09
|
Loading…
Reference in a new issue