From dac7a6f20802acbc2d5e3bc885b74cde0016fc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 9 Feb 2018 21:35:06 +0100 Subject: [PATCH 1/4] Qube manager updates more sensibly Many events now cause the Qube Manager to refresh better - just the appropriate row, for example. --- qubesmanager/qube_manager.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index d0e8204..d3476e0 100755 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -256,7 +256,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.vms_list = [] self.vms_in_table = {} - self.reload_table = False self.frame_width = 0 self.frame_height = 0 @@ -395,6 +394,10 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): def get_vms_list(self): return [vm for vm in self.qubes_app.domains] + def update_single_row(self, vm): + if vm in self.qubes_app.domains: + self.vms_in_table[vm.qid].update() + def fill_table(self): # save current selection row_index = self.table.currentRow() @@ -420,7 +423,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.table.setRowCount(row_no) self.vms_list = vms_list self.vms_in_table = vms_in_table - self.reload_table = False if selected_qid in vms_in_table.keys(): self.table.setCurrentItem( self.vms_in_table[selected_qid].name_widget) @@ -449,9 +451,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): def action_search_triggered(self): self.searchbox.setFocus() - def mark_table_for_update(self): - self.reload_table = True - def update_table(self): self.fill_table() @@ -512,6 +511,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.action_set_keyboard_layout.setEnabled( vm.qid != 0 and vm.get_power_state() != "Paused" and vm.is_running()) + + self.update_single_row(vm) else: self.action_settings.setEnabled(False) self.action_removevm.setEnabled(False) @@ -703,7 +704,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): return self.start_vm(vm) - self.update_table() + self.update_single_row(vm) def start_vm(self, vm): if vm.is_running(): @@ -724,7 +725,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.tr("Error starting Qube!"), self.tr("ERROR: {0}").format(t_monitor.error_msg)) - self.update_table() + self.update_single_row(vm) @staticmethod def do_start_vm(vm, t_monitor): @@ -750,7 +751,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): assert vm.is_running() try: vm.pause() - self.update_table() + self.update_single_row(vm) except exc.QubesException as ex: QtGui.QMessageBox.warning( None, @@ -776,7 +777,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): if reply == QtGui.QMessageBox.Yes: self.shutdown_vm(vm) - self.update_table() + self.update_single_row(vm) def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, check_time=vm_restart_check_timeout, and_restart=False): @@ -814,7 +815,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): if reply == QtGui.QMessageBox.Yes: self.shutdown_vm(vm, and_restart=True) - self.update_table() + self.update_single_row(vm) # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_killvm_triggered') @@ -852,7 +853,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): settings_window = settings.VMSettingsWindow( vm, self.qt_app, "basic") settings_window.exec_() - self.update_table() + self.update_single_row(vm) # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_appmenus_triggered') @@ -912,7 +913,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.tr("Error on Qube update!"), self.tr("ERROR: {0}").format(t_monitor.error_msg)) - self.update_table() + self.update_single_row(vm) @staticmethod def do_update_vm(vm, t_monitor): From 1d995de0955484ea603d2e7ba95cfa19b677f6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 9 Feb 2018 21:59:43 +0100 Subject: [PATCH 2/4] Refreshing vm list in qube manager fixed If a new VM was created via button in vm settings, the refresh button will now correctly display it. --- qubesmanager/qube_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index d3476e0..2bc52bb 100755 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -867,6 +867,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_refresh_list_triggered') def action_refresh_list_triggered(self): + self.qubes_app.domains.clear_cache() self.update_table() # noinspection PyArgumentList From 5af2709029cd551f22847c8d771e694905ff5db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 9 Feb 2018 22:08:07 +0100 Subject: [PATCH 3/4] Shutting down vm from qube manager bug Hopefully, finally fixes issue #3501. fixes QubesOS/qubes-issues#3501 --- qubesmanager/qube_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 2bc52bb..9d8fc2c 100755 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -176,7 +176,7 @@ class VmShutdownMonitor(QtCore.QObject): vm_is_running = vm.is_running() try: vm_start_time = datetime.fromtimestamp(float(vm.start_time)) - except (AttributeError, TypeError): + except (AttributeError, TypeError, ValueError): vm_start_time = None if vm_is_running and vm_start_time \ From 45959aef715f83bc3c892aecffe788dce9e57523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Sat, 10 Feb 2018 23:41:36 +0100 Subject: [PATCH 4/4] Changes according to @marmarek's request --- qubesmanager/qube_manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 9d8fc2c..7559db5 100755 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -395,8 +395,13 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): return [vm for vm in self.qubes_app.domains] def update_single_row(self, vm): + # this fuction should be used to update a row that already exists + # to add a row, one needs to use the update_table function - the + # whole table needs to be redrawn (and sorted) if vm in self.qubes_app.domains: self.vms_in_table[vm.qid].update() + else: + self.update_table() def fill_table(self): # save current selection