Refresh Apps in vm settings now refreshes the vm and template both

requires e26debfe97

fixes QubesOS/qubes-issues#4383
This commit is contained in:
Marta Marczykowska-Górecka 2018-11-30 21:47:15 +01:00
parent 334fefe559
commit f0357623e6
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 23 additions and 18 deletions

View File

@ -93,31 +93,35 @@ class RenameVMThread(QtCore.QThread):
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
class RefreshAppsVMThread(QtCore.QThread): class RefreshAppsVMThread(QtCore.QThread):
def __init__(self, vm): def __init__(self, vm, button):
QtCore.QThread.__init__(self) QtCore.QThread.__init__(self)
self.vm = vm self.vm = vm
self.button = button
self.msg = None self.msg = None
def run(self): 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: try:
target_vm = self.vm.template if not vm.is_running():
except AttributeError: not_running = True
target_vm = self.vm vm.start()
else:
not_running = False
if not target_vm.is_running(): subprocess.check_call(['qvm-sync-appmenus', vm.name])
not_running = True
target_vm.start()
else:
not_running = False
subprocess.check_call(['qvm-sync-appmenus', target_vm.name]) if not_running:
vm.shutdown()
if not_running: except Exception as ex: # pylint: disable=broad-except
target_vm.shutdown() self.msg = ("Refresh failed!", str(ex))
except Exception as ex: # pylint: disable=broad-except
self.msg = ("Refresh failed!", str(ex))
# pylint: disable=too-many-instance-attributes # 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.setEnabled(False)
self.refresh_apps_button.setText(self.tr('Refresh in progress...')) 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.clear_threads)
thread.finished.connect(self.refresh_finished) thread.finished.connect(self.refresh_finished)
self.threads_list.append(thread) self.threads_list.append(thread)

View File

@ -12,6 +12,7 @@ Requires: python3-PyQt4
Requires: python3-inotify Requires: python3-inotify
Requires: python3-qubesadmin >= 4.0.19 Requires: python3-qubesadmin >= 4.0.19
Requires: python3-Quamash Requires: python3-Quamash
Requires: qubes-desktop-linux-common >= 4.0.16
Requires: qubes-artwork Requires: qubes-artwork
Requires: pmount Requires: pmount
Requires: cryptsetup Requires: cryptsetup