Skip to content

Commit 84366b4

Browse files
committed
Improve Qubes OS Update reporting for dom0
fixes: QubesOS/qubes-issues#9355
1 parent 66e5cfb commit 84366b4

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

qui/updater/progress_page.py

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -148,66 +148,67 @@ def update_admin_vm(self, admins):
148148
return
149149
self.log.debug("Start adminVM updating")
150150

151-
info = f"Updating {admin.name}...\n" \
152-
f"{admin.name} does not support in-progress update " \
153-
"information.\n"
151+
info = f"Checking for available updates for {admin.name}...\n"
154152
GLib.idle_add(
155153
admin.append_text_view,
156154
l(info).format(admin.name))
157155
GLib.idle_add(admin.set_status, UpdateStatus.ProgressUnknown)
158156

159157
self.update_details.update_buffer()
160158

161-
try:
162-
with Ticker(admin):
163-
curr_pkg = self._get_packages_admin()
164-
165-
# pylint: disable=consider-using-with
166-
check_updates = subprocess.Popen(
167-
['sudo', 'qubes-dom0-update', '--refresh', '--check-only'],
168-
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
169-
_stdout, stderr = check_updates.communicate()
170-
if check_updates.returncode != 100:
171-
GLib.idle_add(admin.append_text_view, stderr.decode())
172-
if check_updates.returncode != 0:
173-
GLib.idle_add(admin.set_status, UpdateStatus.Error)
174-
else:
175-
GLib.idle_add(
176-
admin.set_status, UpdateStatus.NoUpdatesFound)
177-
self.update_details.update_buffer()
178-
return
179-
180-
proc = subprocess.Popen(
181-
['sudo', 'qubes-dom0-update', '-y'],
182-
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
159+
def qubes_dom0_update(*args):
160+
with subprocess.Popen(['sudo', 'qubes-dom0-update'] + list(args),
161+
stderr=subprocess.PIPE, stdout=subprocess.PIPE) as subproc:
183162

184163
read_err_thread = threading.Thread(
185164
target=self.dump_to_textview,
186-
args=(proc.stderr, admin)
165+
args=(subproc.stderr, admin)
187166
)
188167
read_out_thread = threading.Thread(
189168
target=self.dump_to_textview,
190-
args=(proc.stdout, admin)
169+
args=(subproc.stdout, admin)
191170
)
192171
read_err_thread.start()
193172
read_out_thread.start()
194173

195-
while proc.poll() is None \
174+
while subproc.poll() is None \
196175
or read_out_thread.is_alive() \
197176
or read_err_thread.is_alive():
198177
time.sleep(1)
199-
if self.exit_triggered and proc.poll() is None:
200-
proc.send_signal(signal.SIGINT)
201-
proc.wait()
178+
if self.exit_triggered and subproc.poll() is None:
179+
subproc.send_signal(signal.SIGINT)
180+
subproc.wait()
202181
read_err_thread.join()
203182
read_out_thread.join()
204183

184+
return subproc.returncode
185+
186+
try:
187+
with Ticker(admin):
188+
curr_pkg = self._get_packages_admin()
189+
190+
returncode = qubes_dom0_update('--refresh', '--check-only')
191+
if returncode != 100:
192+
if returncode != 0:
193+
GLib.idle_add(admin.set_status, UpdateStatus.Error)
194+
else:
195+
GLib.idle_add(
196+
admin.set_status, UpdateStatus.NoUpdatesFound)
197+
self.update_details.update_buffer()
198+
return
199+
200+
returncode = qubes_dom0_update('-y')
201+
if returncode != 0:
202+
GLib.idle_add(admin.set_status, UpdateStatus.Error)
203+
self.update_details.update_buffer()
204+
return
205+
205206
new_pkg = self._get_packages_admin()
206207
changes = self._compare_packages(curr_pkg, new_pkg)
207208
changes_str = self._print_changes(changes)
208209
GLib.idle_add(admin.append_text_view, changes_str)
209-
210210
GLib.idle_add(admin.set_status, UpdateStatus.Success)
211+
211212
except subprocess.CalledProcessError as ex:
212213
GLib.idle_add(
213214
admin.append_text_view,

0 commit comments

Comments
 (0)