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.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_()
|
||||
self.vms_in_table[vm.qid].update()
|
||||
|
||||
# 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,31 +1220,34 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
||||
|
||||
@QtCore.pyqtSlot('const QPoint&')
|
||||
def open_context_menu(self, point):
|
||||
vm = self.get_selected_vm()
|
||||
try:
|
||||
vm = self.get_selected_vm()
|
||||
|
||||
# logs menu
|
||||
self.logs_menu.clear()
|
||||
# logs menu
|
||||
self.logs_menu.clear()
|
||||
|
||||
if vm.qid == 0:
|
||||
logfiles = ["/var/log/xen/console/hypervisor.log"]
|
||||
else:
|
||||
logfiles = [
|
||||
"/var/log/xen/console/guest-" + vm.name + ".log",
|
||||
"/var/log/xen/console/guest-" + vm.name + "-dm.log",
|
||||
"/var/log/qubes/guid." + vm.name + ".log",
|
||||
"/var/log/qubes/qrexec." + vm.name + ".log",
|
||||
]
|
||||
if vm.qid == 0:
|
||||
logfiles = ["/var/log/xen/console/hypervisor.log"]
|
||||
else:
|
||||
logfiles = [
|
||||
"/var/log/xen/console/guest-" + vm.name + ".log",
|
||||
"/var/log/xen/console/guest-" + vm.name + "-dm.log",
|
||||
"/var/log/qubes/guid." + vm.name + ".log",
|
||||
"/var/log/qubes/qrexec." + vm.name + ".log",
|
||||
]
|
||||
|
||||
menu_empty = True
|
||||
for logfile in logfiles:
|
||||
if os.path.exists(logfile):
|
||||
action = self.logs_menu.addAction(QtGui.QIcon(":/log.png"),
|
||||
logfile)
|
||||
action.setData(logfile)
|
||||
menu_empty = False
|
||||
menu_empty = True
|
||||
for logfile in logfiles:
|
||||
if os.path.exists(logfile):
|
||||
action = self.logs_menu.addAction(QtGui.QIcon(":/log.png"),
|
||||
logfile)
|
||||
action.setData(logfile)
|
||||
menu_empty = False
|
||||
|
||||
self.logs_menu.setEnabled(not menu_empty)
|
||||
self.context_menu.exec_(self.table.mapToGlobal(point))
|
||||
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):
|
||||
|
@ -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,15 +494,14 @@ 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)
|
||||
self.done(0)
|
||||
if self._run_in_thread(self._rename_vm, new_vm_name):
|
||||
self.done(0)
|
||||
|
||||
def _remove_vm(self, t_monitor):
|
||||
try:
|
||||
|
@ -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,14 +75,18 @@ class VmTypeWidget(VmIconWidget):
|
||||
def set_value(self, value):
|
||||
self.value = value
|
||||
|
||||
#pylint: disable=too-many-return-statements
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
|
||||
def __init__(self, vm, parent=None):
|
||||
(icon_path, tooltip) = self.get_vm_icon(vm)
|
||||
@ -119,14 +125,18 @@ class VmLabelWidget(VmIconWidget):
|
||||
def set_value(self, value):
|
||||
self.value = value
|
||||
|
||||
#pylint: disable=too-many-return-statements
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
|
||||
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):
|
||||
if self.qid == 0:
|
||||
return True
|
||||
elif other.qid == 0:
|
||||
try:
|
||||
if self.qid == 0:
|
||||
return True
|
||||
elif other.qid == 0:
|
||||
return False
|
||||
return super(VmNameItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
return super(VmNameItem, self).__lt__(other)
|
||||
|
||||
|
||||
class VmStatusIcon(QtGui.QLabel):
|
||||
@ -193,9 +207,12 @@ class VmInfoWidget(QtGui.QWidget):
|
||||
|
||||
def __lt__(self, other):
|
||||
# pylint: disable=too-many-return-statements
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
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
|
||||
@ -278,13 +295,16 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
|
||||
self.setText(self.vm.klass)
|
||||
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.text() == other.text():
|
||||
return self.vm.name < other.vm.name
|
||||
return super(VmTemplateItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.text() == other.text():
|
||||
return self.vm.name < other.vm.name
|
||||
return super(VmTemplateItem, self).__lt__(other)
|
||||
|
||||
|
||||
class VmNetvmItem(QtGui.QTableWidgetItem):
|
||||
@ -302,13 +322,16 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
|
||||
self.setText(self.vm.netvm.name)
|
||||
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.text() == other.text():
|
||||
return self.vm.name < other.vm.name
|
||||
return super(VmNetvmItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.text() == other.text():
|
||||
return self.vm.name < other.vm.name
|
||||
return super(VmNetvmItem, self).__lt__(other)
|
||||
|
||||
|
||||
class VmInternalItem(QtGui.QTableWidgetItem):
|
||||
@ -325,11 +348,14 @@ class VmInternalItem(QtGui.QTableWidgetItem):
|
||||
|
||||
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
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
|
||||
return super(VmInternalItem, self).__lt__(other)
|
||||
|
||||
|
||||
# features man qvm-features
|
||||
@ -350,13 +376,16 @@ class VmUpdateInfoWidget(QtGui.QWidget):
|
||||
self.value = 0
|
||||
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
|
||||
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,13 +486,16 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
|
||||
self.setText(str(self.value) + " MiB")
|
||||
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
|
||||
|
||||
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):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
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
|
||||
return super(VmIPItem, self).__lt__(other)
|
||||
|
||||
|
||||
class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
||||
@ -501,13 +536,16 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
||||
self.setText("")
|
||||
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
class VmLastBackupItem(QtGui.QTableWidgetItem):
|
||||
@ -527,15 +565,19 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
|
||||
else:
|
||||
self.setText("")
|
||||
|
||||
#pylint: disable=too-many-return-statements
|
||||
def __lt__(self, other):
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
elif self.backup_timestamp == other.backup_timestamp:
|
||||
return self.vm.name < other.vm.name
|
||||
elif not self.backup_timestamp:
|
||||
return False
|
||||
elif not other.backup_timestamp:
|
||||
return True
|
||||
return self.backup_timestamp < other.backup_timestamp
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
elif self.backup_timestamp == other.backup_timestamp:
|
||||
return self.vm.name < other.vm.name
|
||||
elif not self.backup_timestamp:
|
||||
return False
|
||||
elif not other.backup_timestamp:
|
||||
return True
|
||||
return self.backup_timestamp < other.backup_timestamp
|
||||
|
Loading…
Reference in New Issue
Block a user