Skip to content

Commit

Permalink
Improve Qubes OS Update reporting for dom0
Browse files Browse the repository at this point in the history
  • Loading branch information
alimirjamali committed Jul 16, 2024
1 parent 66e5cfb commit 63ffd63
Showing 1 changed file with 31 additions and 35 deletions.
66 changes: 31 additions & 35 deletions qui/updater/progress_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,47 @@ def update_admin_vm(self, admins):
return
self.log.debug("Start adminVM updating")

info = f"Updating {admin.name}...\n" \
f"{admin.name} does not support in-progress update " \
"information.\n"
info = f"Checking for available updates for {admin.name}...\n"
GLib.idle_add(
admin.append_text_view,
l(info).format(admin.name))
GLib.idle_add(admin.set_status, UpdateStatus.ProgressUnknown)

self.update_details.update_buffer()

def qubes_dom0_update(*args):
subproc = subprocess.Popen(['sudo', 'qubes-dom0-update'] + \
list(args), stderr=subprocess.PIPE, stdout=subprocess.PIPE)

read_err_thread = threading.Thread(
target=self.dump_to_textview,
args=(subproc.stderr, admin)
)
read_out_thread = threading.Thread(
target=self.dump_to_textview,
args=(subproc.stdout, admin)
)
read_err_thread.start()
read_out_thread.start()

while subproc.poll() is None \
or read_out_thread.is_alive() \
or read_err_thread.is_alive():
time.sleep(1)
if self.exit_triggered and subproc.poll() is None:
subproc.send_signal(signal.SIGINT)
subproc.wait()
read_err_thread.join()
read_out_thread.join()

return subproc

try:
with Ticker(admin):
curr_pkg = self._get_packages_admin()

# pylint: disable=consider-using-with
check_updates = subprocess.Popen(
['sudo', 'qubes-dom0-update', '--refresh', '--check-only'],
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
_stdout, stderr = check_updates.communicate()
check_updates = qubes_dom0_update('--refresh', '--check-only')
if check_updates.returncode != 100:
GLib.idle_add(admin.append_text_view, stderr.decode())
if check_updates.returncode != 0:
GLib.idle_add(admin.set_status, UpdateStatus.Error)
else:
Expand All @@ -177,37 +197,13 @@ def update_admin_vm(self, admins):
self.update_details.update_buffer()
return

proc = subprocess.Popen(
['sudo', 'qubes-dom0-update', '-y'],
stderr=subprocess.PIPE, stdout=subprocess.PIPE)

read_err_thread = threading.Thread(
target=self.dump_to_textview,
args=(proc.stderr, admin)
)
read_out_thread = threading.Thread(
target=self.dump_to_textview,
args=(proc.stdout, admin)
)
read_err_thread.start()
read_out_thread.start()

while proc.poll() is None \
or read_out_thread.is_alive() \
or read_err_thread.is_alive():
time.sleep(1)
if self.exit_triggered and proc.poll() is None:
proc.send_signal(signal.SIGINT)
proc.wait()
read_err_thread.join()
read_out_thread.join()

proc = qubes_dom0_update('-y')
new_pkg = self._get_packages_admin()
changes = self._compare_packages(curr_pkg, new_pkg)
changes_str = self._print_changes(changes)
GLib.idle_add(admin.append_text_view, changes_str)

GLib.idle_add(admin.set_status, UpdateStatus.Success)

except subprocess.CalledProcessError as ex:
GLib.idle_add(
admin.append_text_view,
Expand Down

0 comments on commit 63ffd63

Please sign in to comment.