Merge remote-tracking branch 'qubesos/pr/95'

* qubesos/pr/95:
  Revert last and removed pylint disables
  Added BaseException
  Show updates pending while running domain
  Fix search coherence when adding a domain
  Last no-member
  Try with disable=no-member
  Another try for travis
  Disable no-name-in-module
  Fix pylint warnings
  Fix very unlikely case when user right clicks the VM in the exact moment he deletes it.
  Don't close the settings window if something failed when renaming e.g. the VM name already exists
  Revert "Since __lt__ methods are safe, is not needed to stop and reenable sorting."
  Added standalone VM's to check_updates() Also added an initial call when creating the timer, most users will look for updates inmediately after start the manager
  Since __lt__ methods are safe, is not needed to stop and reenable sorting. It causes a short freeze of the main window when reenabling, so better removing it.
  Added try/except for all __lt__() methods since some VM could be deleted before the signal is received and handled.
This commit is contained in:
Marek Marczykowski-Górecki 2018-06-27 03:07:46 +02:00
commit 7a5c304c1e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 148 additions and 94 deletions

View File

@ -392,10 +392,11 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
timer = QtCore.QTimer(self)
timer.timeout.connect(self.check_updates)
timer.start(1000 * 30) # 30s
self.check_updates()
def check_updates(self):
for vm in self.qubes_app.domains:
if vm.klass == 'TemplateVM':
if vm.klass in {'TemplateVM', 'StandaloneVM'}:
self.vms_in_table[vm.qid].update()
def on_domain_added(self, _, domain):
@ -414,6 +415,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
vm_row = VmRowInTable(vm, row_no, self.table)
self.vms_in_table[vm.qid] = vm_row
self.table.setSortingEnabled(True)
self.showhide_vms()
return
# Never should reach here
@ -961,7 +963,13 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
settings_window = settings.VMSettingsWindow(
vm, self.qt_app, "basic")
settings_window.exec_()
# vm could be deleted on renaming
try:
self.vms_in_table[vm.qid].update()
except exc.QubesPropertyAccessError:
pass
# noinspection PyArgumentList
@QtCore.pyqtSlot(name='on_action_appmenus_triggered')
@ -1212,6 +1220,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
@QtCore.pyqtSlot('const QPoint&')
def open_context_menu(self, point):
try:
vm = self.get_selected_vm()
# logs menu
@ -1237,6 +1246,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
self.logs_menu.setEnabled(not menu_empty)
self.context_menu.exec_(self.table.mapToGlobal(point))
except exc.QubesPropertyAccessError:
pass
@QtCore.pyqtSlot('QAction *')
def show_log(self, action):

View File

@ -478,6 +478,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
self.tr("Error!"),
self.tr("ERROR: {}").format(
t_monitor.error_msg))
return False
return True
def _rename_vm(self, t_monitor, name):
try:
@ -492,14 +494,13 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
t_monitor.set_finished()
def rename_vm(self):
new_vm_name, ok = QtGui.QInputDialog.getText(
self,
self.tr('Rename qube'),
self.tr('New name: (WARNING: all other changes will be discarded)'))
if ok:
self._run_in_thread(self._rename_vm, new_vm_name)
if self._run_in_thread(self._rename_vm, new_vm_name):
self.done(0)
def _remove_vm(self, t_monitor):

View File

@ -24,6 +24,8 @@ from PyQt4 import QtGui # pylint: disable=import-error
from PyQt4 import QtCore # pylint: disable=import-error
# pylint: disable=too-few-public-methods
from qubesadmin import exc
power_order = QtCore.Qt.DescendingOrder
update_order = QtCore.Qt.AscendingOrder
@ -73,7 +75,9 @@ class VmTypeWidget(VmIconWidget):
def set_value(self, value):
self.value = value
#pylint: disable=too-many-return-statements
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -81,6 +85,8 @@ class VmTypeWidget(VmIconWidget):
elif self.value == other.value:
return self.vm.name < other.vm.name
return self.value < other.value
except exc.QubesPropertyAccessError:
return False
def __init__(self, vm, parent=None):
(icon_path, tooltip) = self.get_vm_icon(vm)
@ -119,7 +125,9 @@ class VmLabelWidget(VmIconWidget):
def set_value(self, value):
self.value = value
#pylint: disable=too-many-return-statements
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -127,6 +135,8 @@ class VmLabelWidget(VmIconWidget):
elif self.value == other.value:
return self.vm.name < other.vm.name
return self.value < other.value
except exc.QubesPropertyAccessError:
return False
def __init__(self, vm, parent=None):
icon_path = self.get_vm_icon_path(vm)
@ -148,12 +158,16 @@ class VmNameItem(QtGui.QTableWidgetItem):
self.setTextAlignment(QtCore.Qt.AlignVCenter)
self.qid = vm.qid
#pylint: disable=too-many-return-statements
def __lt__(self, other):
try:
if self.qid == 0:
return True
elif other.qid == 0:
return False
return super(VmNameItem, self).__lt__(other)
except exc.QubesPropertyAccessError:
return False
class VmStatusIcon(QtGui.QLabel):
@ -193,10 +207,13 @@ class VmInfoWidget(QtGui.QWidget):
def __lt__(self, other):
# pylint: disable=too-many-return-statements
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
return False
except exc.QubesPropertyAccessError:
return False
self_val = self.upd_info_item.value
other_val = other.upd_info_item.value
@ -278,6 +295,7 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
self.setText(self.vm.klass)
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -285,6 +303,8 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
elif self.text() == other.text():
return self.vm.name < other.vm.name
return super(VmTemplateItem, self).__lt__(other)
except exc.QubesPropertyAccessError:
return False
class VmNetvmItem(QtGui.QTableWidgetItem):
@ -302,6 +322,7 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
self.setText(self.vm.netvm.name)
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -309,6 +330,8 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
elif self.text() == other.text():
return self.vm.name < other.vm.name
return super(VmNetvmItem, self).__lt__(other)
except exc.QubesPropertyAccessError:
return False
class VmInternalItem(QtGui.QTableWidgetItem):
@ -325,11 +348,14 @@ class VmInternalItem(QtGui.QTableWidgetItem):
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
return False
return super(VmInternalItem, self).__lt__(other)
except exc.QubesPropertyAccessError:
return False
# features man qvm-features
@ -350,6 +376,7 @@ class VmUpdateInfoWidget(QtGui.QWidget):
self.value = 0
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -357,6 +384,8 @@ class VmUpdateInfoWidget(QtGui.QWidget):
elif self.value == other.value:
return self.vm.name < other.vm.name
return self.value < other.value
except exc.QubesPropertyAccessError:
return False
def __init__(self, vm, show_text=True, parent=None):
super(VmUpdateInfoWidget, self).__init__(parent)
@ -391,7 +420,7 @@ class VmUpdateInfoWidget(QtGui.QWidget):
outdated_state = "outdated"
break
elif self.vm.klass == 'TemplateVM' and \
if self.vm.klass in {'TemplateVM', 'StandaloneVM'} and \
self.vm.features.get('updates-available', False):
outdated_state = 'update'
@ -457,6 +486,7 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
self.setText(str(self.value) + " MiB")
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -464,6 +494,8 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
elif self.value == other.value:
return self.vm.name < other.vm.name
return self.value < other.value
except exc.QubesPropertyAccessError:
return False
class VmIPItem(QtGui.QTableWidgetItem):
@ -479,11 +511,14 @@ class VmIPItem(QtGui.QTableWidgetItem):
self.setText(self.ip if self.ip is not None else 'n/a')
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
return False
return super(VmIPItem, self).__lt__(other)
except exc.QubesPropertyAccessError:
return False
class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
@ -501,6 +536,7 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
self.setText("")
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -508,6 +544,8 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
elif self.vm.include_in_backups == other.vm.include_in_backups:
return self.vm.name < other.vm.name
return self.vm.include_in_backups < other.vm.include_in_backups
except exc.QubesPropertyAccessError:
return False
class VmLastBackupItem(QtGui.QTableWidgetItem):
@ -527,7 +565,9 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
else:
self.setText("")
#pylint: disable=too-many-return-statements
def __lt__(self, other):
try:
if self.vm.qid == 0:
return True
elif other.vm.qid == 0:
@ -539,3 +579,5 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
elif not other.backup_timestamp:
return True
return self.backup_timestamp < other.backup_timestamp
except exc.QubesPropertyAccessError:
return False