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:
commit
7a5c304c1e
@ -392,10 +392,11 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
|||||||
timer = QtCore.QTimer(self)
|
timer = QtCore.QTimer(self)
|
||||||
timer.timeout.connect(self.check_updates)
|
timer.timeout.connect(self.check_updates)
|
||||||
timer.start(1000 * 30) # 30s
|
timer.start(1000 * 30) # 30s
|
||||||
|
self.check_updates()
|
||||||
|
|
||||||
def check_updates(self):
|
def check_updates(self):
|
||||||
for vm in self.qubes_app.domains:
|
for vm in self.qubes_app.domains:
|
||||||
if vm.klass == 'TemplateVM':
|
if vm.klass in {'TemplateVM', 'StandaloneVM'}:
|
||||||
self.vms_in_table[vm.qid].update()
|
self.vms_in_table[vm.qid].update()
|
||||||
|
|
||||||
def on_domain_added(self, _, domain):
|
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)
|
vm_row = VmRowInTable(vm, row_no, self.table)
|
||||||
self.vms_in_table[vm.qid] = vm_row
|
self.vms_in_table[vm.qid] = vm_row
|
||||||
self.table.setSortingEnabled(True)
|
self.table.setSortingEnabled(True)
|
||||||
|
self.showhide_vms()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Never should reach here
|
# Never should reach here
|
||||||
@ -961,7 +963,13 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
|||||||
settings_window = settings.VMSettingsWindow(
|
settings_window = settings.VMSettingsWindow(
|
||||||
vm, self.qt_app, "basic")
|
vm, self.qt_app, "basic")
|
||||||
settings_window.exec_()
|
settings_window.exec_()
|
||||||
|
|
||||||
|
# vm could be deleted on renaming
|
||||||
|
try:
|
||||||
self.vms_in_table[vm.qid].update()
|
self.vms_in_table[vm.qid].update()
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyArgumentList
|
# noinspection PyArgumentList
|
||||||
@QtCore.pyqtSlot(name='on_action_appmenus_triggered')
|
@QtCore.pyqtSlot(name='on_action_appmenus_triggered')
|
||||||
@ -1212,6 +1220,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot('const QPoint&')
|
@QtCore.pyqtSlot('const QPoint&')
|
||||||
def open_context_menu(self, point):
|
def open_context_menu(self, point):
|
||||||
|
try:
|
||||||
vm = self.get_selected_vm()
|
vm = self.get_selected_vm()
|
||||||
|
|
||||||
# logs menu
|
# logs menu
|
||||||
@ -1237,6 +1246,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
|||||||
|
|
||||||
self.logs_menu.setEnabled(not menu_empty)
|
self.logs_menu.setEnabled(not menu_empty)
|
||||||
self.context_menu.exec_(self.table.mapToGlobal(point))
|
self.context_menu.exec_(self.table.mapToGlobal(point))
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
pass
|
||||||
|
|
||||||
@QtCore.pyqtSlot('QAction *')
|
@QtCore.pyqtSlot('QAction *')
|
||||||
def show_log(self, action):
|
def show_log(self, action):
|
||||||
|
@ -478,6 +478,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
|
|||||||
self.tr("Error!"),
|
self.tr("Error!"),
|
||||||
self.tr("ERROR: {}").format(
|
self.tr("ERROR: {}").format(
|
||||||
t_monitor.error_msg))
|
t_monitor.error_msg))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def _rename_vm(self, t_monitor, name):
|
def _rename_vm(self, t_monitor, name):
|
||||||
try:
|
try:
|
||||||
@ -492,14 +494,13 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
|
|||||||
t_monitor.set_finished()
|
t_monitor.set_finished()
|
||||||
|
|
||||||
def rename_vm(self):
|
def rename_vm(self):
|
||||||
|
|
||||||
new_vm_name, ok = QtGui.QInputDialog.getText(
|
new_vm_name, ok = QtGui.QInputDialog.getText(
|
||||||
self,
|
self,
|
||||||
self.tr('Rename qube'),
|
self.tr('Rename qube'),
|
||||||
self.tr('New name: (WARNING: all other changes will be discarded)'))
|
self.tr('New name: (WARNING: all other changes will be discarded)'))
|
||||||
|
|
||||||
if ok:
|
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)
|
self.done(0)
|
||||||
|
|
||||||
def _remove_vm(self, t_monitor):
|
def _remove_vm(self, t_monitor):
|
||||||
|
@ -24,6 +24,8 @@ from PyQt4 import QtGui # pylint: disable=import-error
|
|||||||
from PyQt4 import QtCore # pylint: disable=import-error
|
from PyQt4 import QtCore # pylint: disable=import-error
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
from qubesadmin import exc
|
||||||
|
|
||||||
power_order = QtCore.Qt.DescendingOrder
|
power_order = QtCore.Qt.DescendingOrder
|
||||||
update_order = QtCore.Qt.AscendingOrder
|
update_order = QtCore.Qt.AscendingOrder
|
||||||
|
|
||||||
@ -73,7 +75,9 @@ class VmTypeWidget(VmIconWidget):
|
|||||||
def set_value(self, value):
|
def set_value(self, value):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
#pylint: disable=too-many-return-statements
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -81,6 +85,8 @@ class VmTypeWidget(VmIconWidget):
|
|||||||
elif self.value == other.value:
|
elif self.value == other.value:
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return self.value < other.value
|
return self.value < other.value
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
def __init__(self, vm, parent=None):
|
def __init__(self, vm, parent=None):
|
||||||
(icon_path, tooltip) = self.get_vm_icon(vm)
|
(icon_path, tooltip) = self.get_vm_icon(vm)
|
||||||
@ -119,7 +125,9 @@ class VmLabelWidget(VmIconWidget):
|
|||||||
def set_value(self, value):
|
def set_value(self, value):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
#pylint: disable=too-many-return-statements
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -127,6 +135,8 @@ class VmLabelWidget(VmIconWidget):
|
|||||||
elif self.value == other.value:
|
elif self.value == other.value:
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return self.value < other.value
|
return self.value < other.value
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
def __init__(self, vm, parent=None):
|
def __init__(self, vm, parent=None):
|
||||||
icon_path = self.get_vm_icon_path(vm)
|
icon_path = self.get_vm_icon_path(vm)
|
||||||
@ -148,12 +158,16 @@ class VmNameItem(QtGui.QTableWidgetItem):
|
|||||||
self.setTextAlignment(QtCore.Qt.AlignVCenter)
|
self.setTextAlignment(QtCore.Qt.AlignVCenter)
|
||||||
self.qid = vm.qid
|
self.qid = vm.qid
|
||||||
|
|
||||||
|
#pylint: disable=too-many-return-statements
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.qid == 0:
|
if self.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.qid == 0:
|
elif other.qid == 0:
|
||||||
return False
|
return False
|
||||||
return super(VmNameItem, self).__lt__(other)
|
return super(VmNameItem, self).__lt__(other)
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class VmStatusIcon(QtGui.QLabel):
|
class VmStatusIcon(QtGui.QLabel):
|
||||||
@ -193,10 +207,13 @@ class VmInfoWidget(QtGui.QWidget):
|
|||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
# pylint: disable=too-many-return-statements
|
# pylint: disable=too-many-return-statements
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
return False
|
return False
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
self_val = self.upd_info_item.value
|
self_val = self.upd_info_item.value
|
||||||
other_val = other.upd_info_item.value
|
other_val = other.upd_info_item.value
|
||||||
@ -278,6 +295,7 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
|
|||||||
self.setText(self.vm.klass)
|
self.setText(self.vm.klass)
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -285,6 +303,8 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
|
|||||||
elif self.text() == other.text():
|
elif self.text() == other.text():
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return super(VmTemplateItem, self).__lt__(other)
|
return super(VmTemplateItem, self).__lt__(other)
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class VmNetvmItem(QtGui.QTableWidgetItem):
|
class VmNetvmItem(QtGui.QTableWidgetItem):
|
||||||
@ -302,6 +322,7 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
|
|||||||
self.setText(self.vm.netvm.name)
|
self.setText(self.vm.netvm.name)
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -309,6 +330,8 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
|
|||||||
elif self.text() == other.text():
|
elif self.text() == other.text():
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return super(VmNetvmItem, self).__lt__(other)
|
return super(VmNetvmItem, self).__lt__(other)
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class VmInternalItem(QtGui.QTableWidgetItem):
|
class VmInternalItem(QtGui.QTableWidgetItem):
|
||||||
@ -325,11 +348,14 @@ class VmInternalItem(QtGui.QTableWidgetItem):
|
|||||||
|
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
return False
|
return False
|
||||||
return super(VmInternalItem, self).__lt__(other)
|
return super(VmInternalItem, self).__lt__(other)
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
# features man qvm-features
|
# features man qvm-features
|
||||||
@ -350,6 +376,7 @@ class VmUpdateInfoWidget(QtGui.QWidget):
|
|||||||
self.value = 0
|
self.value = 0
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -357,6 +384,8 @@ class VmUpdateInfoWidget(QtGui.QWidget):
|
|||||||
elif self.value == other.value:
|
elif self.value == other.value:
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return self.value < other.value
|
return self.value < other.value
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
def __init__(self, vm, show_text=True, parent=None):
|
def __init__(self, vm, show_text=True, parent=None):
|
||||||
super(VmUpdateInfoWidget, self).__init__(parent)
|
super(VmUpdateInfoWidget, self).__init__(parent)
|
||||||
@ -391,7 +420,7 @@ class VmUpdateInfoWidget(QtGui.QWidget):
|
|||||||
outdated_state = "outdated"
|
outdated_state = "outdated"
|
||||||
break
|
break
|
||||||
|
|
||||||
elif self.vm.klass == 'TemplateVM' and \
|
if self.vm.klass in {'TemplateVM', 'StandaloneVM'} and \
|
||||||
self.vm.features.get('updates-available', False):
|
self.vm.features.get('updates-available', False):
|
||||||
outdated_state = 'update'
|
outdated_state = 'update'
|
||||||
|
|
||||||
@ -457,6 +486,7 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
|
|||||||
self.setText(str(self.value) + " MiB")
|
self.setText(str(self.value) + " MiB")
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -464,6 +494,8 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
|
|||||||
elif self.value == other.value:
|
elif self.value == other.value:
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return self.value < other.value
|
return self.value < other.value
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class VmIPItem(QtGui.QTableWidgetItem):
|
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')
|
self.setText(self.ip if self.ip is not None else 'n/a')
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
return False
|
return False
|
||||||
return super(VmIPItem, self).__lt__(other)
|
return super(VmIPItem, self).__lt__(other)
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
||||||
@ -501,6 +536,7 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
|||||||
self.setText("")
|
self.setText("")
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -508,6 +544,8 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
|||||||
elif self.vm.include_in_backups == other.vm.include_in_backups:
|
elif self.vm.include_in_backups == other.vm.include_in_backups:
|
||||||
return self.vm.name < other.vm.name
|
return self.vm.name < other.vm.name
|
||||||
return self.vm.include_in_backups < other.vm.include_in_backups
|
return self.vm.include_in_backups < other.vm.include_in_backups
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class VmLastBackupItem(QtGui.QTableWidgetItem):
|
class VmLastBackupItem(QtGui.QTableWidgetItem):
|
||||||
@ -527,7 +565,9 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
|
|||||||
else:
|
else:
|
||||||
self.setText("")
|
self.setText("")
|
||||||
|
|
||||||
|
#pylint: disable=too-many-return-statements
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
return True
|
return True
|
||||||
elif other.vm.qid == 0:
|
elif other.vm.qid == 0:
|
||||||
@ -539,3 +579,5 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
|
|||||||
elif not other.backup_timestamp:
|
elif not other.backup_timestamp:
|
||||||
return True
|
return True
|
||||||
return self.backup_timestamp < other.backup_timestamp
|
return self.backup_timestamp < other.backup_timestamp
|
||||||
|
except exc.QubesPropertyAccessError:
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user