From dd6c336b858dc58cd28b7e18ba564856c6a4a03a Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 27 Feb 2020 15:44:13 -0800 Subject: [PATCH] Force updating the container if flmcode/dangerzone image is not there, and show slightly more output when pulling the image --- dangerzone/settings_widget.py | 2 +- dangerzone/tasks.py | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dangerzone/settings_widget.py b/dangerzone/settings_widget.py index 9c4bb13..76caf36 100644 --- a/dangerzone/settings_widget.py +++ b/dangerzone/settings_widget.py @@ -136,7 +136,7 @@ class SettingsWidget(QtWidgets.QWidget): # Is update containers required? output = subprocess.check_output( - [self.global_common.container_runtime, "image", "ls", "dangerzone"], + [self.global_common.container_runtime, "image", "ls", "flmcode/dangerzone"], startupinfo=self.global_common.get_subprocess_startupinfo(), ) if b"dangerzone" not in output: diff --git a/dangerzone/tasks.py b/dangerzone/tasks.py index 2697986..3bb36e1 100644 --- a/dangerzone/tasks.py +++ b/dangerzone/tasks.py @@ -15,7 +15,7 @@ class TaskBase(QtCore.QThread): def __init__(self): super(TaskBase, self).__init__() - def exec_container(self, args, watch="stdout"): + def exec_container(self, args): args = [self.global_common.container_runtime] + args args_str = " ".join(pipes.quote(s) for s in args) @@ -33,20 +33,12 @@ class TaskBase(QtCore.QThread): universal_newlines=True, startupinfo=self.global_common.get_subprocess_startupinfo(), ) as p: - if watch == "stdout": - pipe = p.stdout - else: - pipe = p.stderr - - for line in pipe: + for line in p.stdout: output += line print(line, end="") self.update_details.emit(output) - if watch == "stdout": - output += p.stderr.read() - else: - output += p.stdout.read() + output += p.stderr.read() self.update_details.emit(output) return p.returncode, output @@ -59,10 +51,12 @@ class PullImageTask(TaskBase): self.common = common def run(self): - self.update_label.emit("Pulling container image") + self.update_label.emit( + "Pulling container image (this might take a few minutes)" + ) self.update_details.emit("") args = ["pull", "flmcode/dangerzone"] - returncode, _ = self.exec_container(args, watch="stderr") + returncode, _ = self.exec_container(args) if returncode != 0: self.task_failed.emit(f"Return code: {returncode}")