From f0357623e6a9bcbd92693121f40fa37b51589ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 30 Nov 2018 21:47:15 +0100 Subject: [PATCH] Refresh Apps in vm settings now refreshes the vm and template both requires https://github.com/QubesOS/qubes-desktop-linux-common/commit/e26debfe97b7c252ab9e34611298745e135083c6 fixes QubesOS/qubes-issues#4383 --- qubesmanager/settings.py | 40 ++++++++++++++++++++++------------------ rpm_spec/qmgr.spec.in | 1 + 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 363c5f4..255f528 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -93,31 +93,35 @@ class RenameVMThread(QtCore.QThread): # pylint: disable=too-few-public-methods class RefreshAppsVMThread(QtCore.QThread): - def __init__(self, vm): + def __init__(self, vm, button): QtCore.QThread.__init__(self) self.vm = vm + self.button = button self.msg = None def run(self): - try: + vms_to_refresh = [self.vm] + template = getattr(self.vm, 'template', None) + if template: + vms_to_refresh.append(template) + + for vm in vms_to_refresh: + self.button.setText( + self.tr('Refresh in progress (refreshing applications ' + 'from {})').format(vm.name)) try: - target_vm = self.vm.template - except AttributeError: - target_vm = self.vm + if not vm.is_running(): + not_running = True + vm.start() + else: + not_running = False - if not target_vm.is_running(): - not_running = True - target_vm.start() - else: - not_running = False + subprocess.check_call(['qvm-sync-appmenus', vm.name]) - subprocess.check_call(['qvm-sync-appmenus', target_vm.name]) - - if not_running: - target_vm.shutdown() - - except Exception as ex: # pylint: disable=broad-except - self.msg = ("Refresh failed!", str(ex)) + if not_running: + vm.shutdown() + except Exception as ex: # pylint: disable=broad-except + self.msg = ("Refresh failed!", str(ex)) # pylint: disable=too-many-instance-attributes @@ -982,7 +986,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.refresh_apps_button.setEnabled(False) self.refresh_apps_button.setText(self.tr('Refresh in progress...')) - thread = RefreshAppsVMThread(self.vm) + thread = RefreshAppsVMThread(self.vm, self.refresh_apps_button) thread.finished.connect(self.clear_threads) thread.finished.connect(self.refresh_finished) self.threads_list.append(thread) diff --git a/rpm_spec/qmgr.spec.in b/rpm_spec/qmgr.spec.in index b00e42e..11a6b3f 100644 --- a/rpm_spec/qmgr.spec.in +++ b/rpm_spec/qmgr.spec.in @@ -12,6 +12,7 @@ Requires: python3-PyQt4 Requires: python3-inotify Requires: python3-qubesadmin >= 4.0.19 Requires: python3-Quamash +Requires: qubes-desktop-linux-common >= 4.0.16 Requires: qubes-artwork Requires: pmount Requires: cryptsetup