Added proper error handling and Check netvm_name is not None

This commit is contained in:
donoban 2020-12-11 00:38:06 +01:00
parent f90ab86a73
commit 0cb89e611a
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5

View File

@ -820,8 +820,20 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
QMessageBox.Yes | QMessageBox.Cancel)
if reply == QMessageBox.Yes:
failed = []
for info in selected_vms:
try:
info.vm.template = template
except:
failed.append(info.name)
if failed:
info_dialog = QMessageBox(self)
info_dialog.setWindowTitle(self.tr("Warning!"))
info_dialog.setText(
self.tr("Some template change failed: {0} "
).format(", ".join(failed)))
info_dialog.show()
def change_network(self, netvm_name):
selected_vms = self.get_selected_vms()
@ -836,6 +848,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
return
try:
if netvm_name is not None:
check_power = any(info.state['power'] == 'Running' for info
in self.get_selected_vms())
netvm = self.qubes_cache.get_vm(name=netvm_name)
@ -853,8 +866,21 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
else:
return
failed = []
for info in self.get_selected_vms():
try:
info.vm.netvm = netvm_name
except:
failed.append(info.name)
if failed:
info_dialog = QMessageBox(self)
info_dialog.setWindowTitle(self.tr("Warning!"))
info_dialog.setText(
self.tr("Some network change failed: {0} "
).format(", ".join(failed)))
info_dialog.show()
except exc.QubesValueError as ex:
QMessageBox.warning(
self,