From 45e60baecb5a774feaf0fd674c0e46090b679e64 Mon Sep 17 00:00:00 2001 From: donoban Date: Sat, 13 Mar 2021 23:40:26 +0100 Subject: [PATCH 01/16] Improved window size and margins --- ui/bootfromdevice.ui | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ui/bootfromdevice.ui b/ui/bootfromdevice.ui index 741ad91..943019c 100644 --- a/ui/bootfromdevice.ui +++ b/ui/bootfromdevice.ui @@ -6,7 +6,7 @@ 0 0 - 600 + 610 170 @@ -27,16 +27,34 @@ Boot qube from device - + 0 30 581 - 72 + 74 + + 6 + + + 6 + + + 6 + + + 6 + + + 0 + + + 6 + From 57130043e3970f6d511e1b9112844565b4737347 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 00:20:08 +0100 Subject: [PATCH 02/16] Removed qvm_start call from bootfromdevice Returns cdrom_location and handles it from caller --- qubesmanager/bootfromdevice.py | 11 ++++------- qubesmanager/settings.py | 9 +++++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index e73493d..1ed9d60 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -23,7 +23,6 @@ from . import utils from . import ui_bootfromdevice # pylint: disable=no-name-in-module from PyQt5 import QtWidgets, QtGui # pylint: disable=import-error from qubesadmin import tools -from qubesadmin.tools import qvm_start from qubesadmin import exc @@ -35,6 +34,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, self.vm = vm self.qapp = qapp self.qubesapp = qubesapp + self.cdrom_location = None self.setupUi(self) self.setWindowTitle( @@ -57,9 +57,9 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, def save_and_apply(self): if self.blockDeviceRadioButton.isChecked(): - cdrom_location = self.blockDeviceComboBox.currentText() + self.cdrom_location = self.blockDeviceComboBox.currentText() elif self.fileRadioButton.isChecked(): - cdrom_location = str(self.fileVM.currentData()) + \ + self.cdrom_location = str(self.fileVM.currentData()) + \ ":" + self.pathText.text() else: QtWidgets.QMessageBox.warning( @@ -70,10 +70,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, # warn user if the VM is currently running self.__warn_if_running__() - - qvm_start.main(['--cdrom', cdrom_location, self.vm.name]) - - self.done(0) + self.accept() def __warn_if_running__(self): try: diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index ce77905..b9c0b6a 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -30,8 +30,10 @@ import traceback from qubesadmin.tools import QubesArgumentParser from qubesadmin import devices from qubesadmin import utils as admin_utils +from qubesadmin.tools import qvm_start import qubesadmin.exc +from . import bootfromdevice from . import utils from . import multiselectwidget from . import common_threads @@ -1022,8 +1024,11 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.check_mem_changes() def boot_from_cdrom_button_pressed(self): - self.save_and_apply() - subprocess.check_call(['qubes-vm-boot-from-device', self.vm.name]) + boot_dialog = bootfromdevice.VMBootFromDeviceWindow( + self.vm, self.qapp, self.qubesapp, self) + if boot_dialog.exec_(): + self.save_and_apply() + qvm_start.main(['--cdrom', boot_dialog.cdrom_location, self.vm.name]) def virt_mode_changed(self, new_idx): # pylint: disable=unused-argument self.update_pv_warning() From 31f4297c7d2ade31594cfd002d9ade28b07954e7 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 00:24:51 +0100 Subject: [PATCH 03/16] Removed unneded reject() definition --- qubesmanager/create_new_vm.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index a95792d..3ba22ef 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -173,9 +173,6 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): self.launch_settings.stateChanged.connect(self.settings_change) self.install_system.stateChanged.connect(self.install_change) - def reject(self): - self.done(0) - def accept(self): vmclass = self.vm_type.currentData() From 094ec9982915ec7e931c9ee5395a9c803e775f15 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 13:21:24 +0100 Subject: [PATCH 04/16] Use vm.name instead vm object This helps create_new_vm since we don't have the vm yet --- qubesmanager/bootfromdevice.py | 7 ++++--- qubesmanager/settings.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index 1ed9d60..73f629e 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -38,7 +38,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, self.setupUi(self) self.setWindowTitle( - self.tr("Boot {vm} from device").format(vm=self.vm.name)) + self.tr("Boot {vm} from device").format(vm=self.vm)) self.buttonBox.accepted.connect(self.save_and_apply) self.buttonBox.rejected.connect(self.reject) @@ -74,7 +74,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, def __warn_if_running__(self): try: - if self.vm.is_running(): + if self.qubesapp.domains[self.vm].is_running(): QtWidgets.QMessageBox.warning( self, self.tr("Warning!"), @@ -104,7 +104,8 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, ) device_choice = [] - for domain in self.vm.app.domains: + + for domain in self.qubesapp.domains: try: for device in domain.devices["block"]: device_choice.append((str(device), device)) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index b9c0b6a..51af4a4 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -1025,7 +1025,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): def boot_from_cdrom_button_pressed(self): boot_dialog = bootfromdevice.VMBootFromDeviceWindow( - self.vm, self.qapp, self.qubesapp, self) + self.vm.name, self.qapp, self.qubesapp, self) if boot_dialog.exec_(): self.save_and_apply() qvm_start.main(['--cdrom', boot_dialog.cdrom_location, self.vm.name]) From 70ea6e2591edc4cb8cdf6d069120cb8d5815910e Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 13:22:25 +0100 Subject: [PATCH 05/16] Removed unneeded reject() definition --- qubesmanager/bootfromdevice.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index 73f629e..683ce80 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -41,7 +41,6 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, self.tr("Boot {vm} from device").format(vm=self.vm)) self.buttonBox.accepted.connect(self.save_and_apply) - self.buttonBox.rejected.connect(self.reject) # populate buttons and such self.__init_buttons__() @@ -52,9 +51,6 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, self.qapp.setApplicationName(self.tr("Boot Qube From Device")) self.qapp.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager")) - def reject(self): - self.done(0) - def save_and_apply(self): if self.blockDeviceRadioButton.isChecked(): self.cdrom_location = self.blockDeviceComboBox.currentText() From cbae4f5868af65a17cb45216a9b44b32ddf5dd6f Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 13:23:43 +0100 Subject: [PATCH 06/16] Added bootfromdevice dialog to create_new_vm (instead subprocess.call) --- qubesmanager/bootfromdevice.py | 6 +++++- qubesmanager/create_new_vm.py | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index 683ce80..e408adf 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -28,13 +28,14 @@ from qubesadmin import exc class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, QtWidgets.QDialog): - def __init__(self, vm, qapp, qubesapp=None, parent=None): + def __init__(self, vm, qapp, qubesapp=None, parent=None, new_vm = False): super().__init__(parent) self.vm = vm self.qapp = qapp self.qubesapp = qubesapp self.cdrom_location = None + self.new_vm = new_vm self.setupUi(self) self.setWindowTitle( @@ -69,6 +70,9 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, self.accept() def __warn_if_running__(self): + if self.new_vm: + return + try: if self.qubesapp.domains[self.vm].is_running(): QtWidgets.QMessageBox.warning( diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index 3ba22ef..3ebcd5f 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -32,6 +32,7 @@ import qubesadmin.tools import qubesadmin.exc from . import utils +from . import bootfromdevice from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error @@ -102,6 +103,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): self.thread = None self.progress = None + self.boot_dialog = None utils.initialize_widget_with_labels( widget=self.label, @@ -175,9 +177,14 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): def accept(self): vmclass = self.vm_type.currentData() - name = str(self.name.text()) + if self.install_system.isChecked(): + self.boot_dialog = bootfromdevice.VMBootFromDeviceWindow( + name, self.qtapp, self.app, self, True) + if not self.boot_dialog.exec_(): + return + if name in self.app.domains: QtWidgets.QMessageBox.warning( self, @@ -227,6 +234,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): def create_finished(self): self.progress.hide() + self.done(0) if self.thread.msg: QtWidgets.QMessageBox.warning( @@ -234,15 +242,15 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): self.tr("Error creating the qube!"), self.tr("ERROR: {0}").format(self.thread.msg)) - self.done(0) - - if not self.thread.msg: + else: if self.launch_settings.isChecked(): subprocess.check_call(['qubes-vm-settings', str(self.name.text())]) if self.install_system.isChecked(): - subprocess.check_call( - ['qubes-vm-boot-from-device', str(self.name.text())]) + qubesadmin.tools.qvm_start.main( + ['--cdrom', self.boot_dialog.cdrom_location, + self.name.text()]) + def type_change(self): template = self.template_vm.currentData() From f0d8b71b22595ee1fd268c242bc60d34446286ec Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 13:24:55 +0100 Subject: [PATCH 07/16] Fix 'Line too long' --- qubesmanager/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 51af4a4..aefd788 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -1028,7 +1028,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): self.vm.name, self.qapp, self.qubesapp, self) if boot_dialog.exec_(): self.save_and_apply() - qvm_start.main(['--cdrom', boot_dialog.cdrom_location, self.vm.name]) + qvm_start.main( + ['--cdrom', boot_dialog.cdrom_location, self.vm.name]) def virt_mode_changed(self, new_idx): # pylint: disable=unused-argument self.update_pv_warning() From 012256d446ce7e421cabca7f8f763a738ed874ad Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 13:27:00 +0100 Subject: [PATCH 08/16] Fix pylint warning --- qubesmanager/bootfromdevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index e408adf..bcf48ab 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -28,7 +28,7 @@ from qubesadmin import exc class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, QtWidgets.QDialog): - def __init__(self, vm, qapp, qubesapp=None, parent=None, new_vm = False): + def __init__(self, vm, qapp, qubesapp=None, parent=None, new_vm=False): super().__init__(parent) self.vm = vm From f050c9d78cee451155bd2f39fde8d5c9ddfabd35 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 14:02:31 +0100 Subject: [PATCH 09/16] Close dialog after finish qvm_start() If not user has few seconds of unresponsive manager --- qubesmanager/create_new_vm.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index 3ebcd5f..e803814 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -233,9 +233,6 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): self.progress.show() def create_finished(self): - self.progress.hide() - self.done(0) - if self.thread.msg: QtWidgets.QMessageBox.warning( self, @@ -251,6 +248,8 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg): ['--cdrom', self.boot_dialog.cdrom_location, self.name.text()]) + self.progress.hide() + self.done(0) def type_change(self): template = self.template_vm.currentData() From 7119c9e5b731a01a0b732cb1e26fddc7ced73969 Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 14:11:04 +0100 Subject: [PATCH 10/16] Restored reject() call with ui --- ui/bootfromdevice.ui | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/bootfromdevice.ui b/ui/bootfromdevice.ui index 943019c..25af8aa 100644 --- a/ui/bootfromdevice.ui +++ b/ui/bootfromdevice.ui @@ -131,5 +131,22 @@ - + + + buttonBox + rejected() + BootDialog + reject() + + + 304 + 146 + + + 304 + 84 + + + + From 7218e6ec562aae6e11984c4862d331b9e0a29aaa Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 18:23:18 +0100 Subject: [PATCH 11/16] Revert "Restored reject() call with ui" This reverts commit 7119c9e5b731a01a0b732cb1e26fddc7ced73969. --- ui/bootfromdevice.ui | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/ui/bootfromdevice.ui b/ui/bootfromdevice.ui index 25af8aa..943019c 100644 --- a/ui/bootfromdevice.ui +++ b/ui/bootfromdevice.ui @@ -131,22 +131,5 @@ - - - buttonBox - rejected() - BootDialog - reject() - - - 304 - 146 - - - 304 - 84 - - - - + From 9fc151b1c95a1d7873d69ebad7a98386fe426b6b Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 14 Mar 2021 18:29:32 +0100 Subject: [PATCH 12/16] Retored reject() connect --- qubesmanager/bootfromdevice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index bcf48ab..d370131 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -42,6 +42,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, self.tr("Boot {vm} from device").format(vm=self.vm)) self.buttonBox.accepted.connect(self.save_and_apply) + self.buttonBox.rejected.connect(self.reject) # populate buttons and such self.__init_buttons__() From a90642712b7ee961ab1d7653d1a85ca758df918d Mon Sep 17 00:00:00 2001 From: donoban Date: Mon, 15 Mar 2021 15:13:59 +0100 Subject: [PATCH 13/16] Added parent to all __init__() --- qubesmanager/about.py | 22 ++++++++++------------ qubesmanager/informationnotes.py | 4 ++-- qubesmanager/qube_manager.py | 12 ++++++------ qubesmanager/releasenotes.py | 4 ++-- qubesmanager/template_manager.py | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/qubesmanager/about.py b/qubesmanager/about.py index da3f398..f8b9b03 100644 --- a/qubesmanager/about.py +++ b/qubesmanager/about.py @@ -30,8 +30,8 @@ from . import ui_about # pylint: disable=no-name-in-module # pylint: disable=too-few-public-methods class AboutDialog(ui_about.Ui_AboutDialog, QDialog): - def __init__(self): - super().__init__() + def __init__(self, parent=None): + super().__init__(parent) self.setupUi(self) @@ -40,15 +40,13 @@ class AboutDialog(ui_about.Ui_AboutDialog, QDialog): self.release.setText(release_file.read()) self.ok.clicked.connect(self.accept) - self.releaseNotes.clicked.connect(on_release_notes_clicked) - self.informationNotes.clicked.connect(on_information_notes_clicked) + self.releaseNotes.clicked.connect(self.on_release_notes_clicked) + self.informationNotes.clicked.connect(self.on_information_notes_clicked) + def on_release_notes_clicked(self): + release_notes_dialog = ReleaseNotesDialog(self) + release_notes_dialog.exec_() -def on_release_notes_clicked(): - release_notes_dialog = ReleaseNotesDialog() - release_notes_dialog.exec_() - - -def on_information_notes_clicked(): - information_notes_dialog = InformationNotesDialog() - information_notes_dialog.exec_() + def on_information_notes_clicked(self): + information_notes_dialog = InformationNotesDialog(self) + information_notes_dialog.exec_() diff --git a/qubesmanager/informationnotes.py b/qubesmanager/informationnotes.py index 4383aac..755be5b 100644 --- a/qubesmanager/informationnotes.py +++ b/qubesmanager/informationnotes.py @@ -29,8 +29,8 @@ import subprocess class InformationNotesDialog(ui_informationnotes.Ui_InformationNotesDialog, QDialog): # pylint: disable=too-few-public-methods - def __init__(self): - super().__init__() + def __init__(self, parent=None): + super().__init__(parent) self.setupUi(self) details = subprocess.check_output( diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index e9e61df..330bb53 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1275,7 +1275,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): @pyqtSlot(name='on_action_createvm_triggered') def action_createvm_triggered(self): with common_threads.busy_cursor(): - create_window = create_new_vm.NewVmDlg(self.qt_app, self.qubes_app) + create_window = create_new_vm.NewVmDlg(self.qt_app, self.qubes_app, self) create_window.exec_() # noinspection PyArgumentList @@ -1493,8 +1493,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): try: with common_threads.busy_cursor(): settings_window = settings.VMSettingsWindow( - vm, init_page=tab, qapp=self.qt_app, - qubesapp=self.qubes_app) + vm, tab, self.qt_app, self.qubes_app, self) settings_window.show() self.settings_windows[vm.name] = settings_window except exc.QubesException as ex: @@ -1597,7 +1596,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): with common_threads.busy_cursor(): global_settings_window = global_settings.GlobalSettingsWindow( self.qt_app, - self.qubes_app) + self.qubes_app, + self) global_settings_window.show() self.settings_windows['global_settings_window'] = global_settings_window @@ -1620,7 +1620,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): def action_restore_triggered(self): with common_threads.busy_cursor(): restore_window = restore.RestoreVMsWindow(self.qt_app, - self.qubes_app) + self.qubes_app, self) restore_window.exec_() # noinspection PyArgumentList @@ -1670,7 +1670,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): # noinspection PyArgumentList @pyqtSlot(name='on_action_about_qubes_triggered') def action_about_qubes_triggered(self): # pylint: disable=no-self-use - about = AboutDialog() + about = AboutDialog(self) about.exec_() def createPopupMenu(self): # pylint: disable=invalid-name diff --git a/qubesmanager/releasenotes.py b/qubesmanager/releasenotes.py index b91fb57..7c30caf 100644 --- a/qubesmanager/releasenotes.py +++ b/qubesmanager/releasenotes.py @@ -27,8 +27,8 @@ from . import ui_releasenotes # pylint: disable=no-name-in-module class ReleaseNotesDialog(ui_releasenotes.Ui_ReleaseNotesDialog, QDialog): # pylint: disable=too-few-public-methods - def __init__(self): - super().__init__() + def __init__(self, parent=None): + super().__init__(parent) self.setupUi(self) diff --git a/qubesmanager/template_manager.py b/qubesmanager/template_manager.py index 6ed44e0..4536df6 100644 --- a/qubesmanager/template_manager.py +++ b/qubesmanager/template_manager.py @@ -35,7 +35,7 @@ class TemplateManagerWindow( def __init__(self, qt_app, qubes_app, dispatcher, parent=None): # pylint: disable=unused-argument - super().__init__() + super().__init__(parent) self.setupUi(self) self.qubes_app = qubes_app From f1f80556dc9fce27e6f15b94841a43bb72154527 Mon Sep 17 00:00:00 2001 From: donoban Date: Mon, 15 Mar 2021 21:12:59 +0100 Subject: [PATCH 14/16] Fix pylint warning --- qubesmanager/qube_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 330bb53..0bcead0 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -1275,7 +1275,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): @pyqtSlot(name='on_action_createvm_triggered') def action_createvm_triggered(self): with common_threads.busy_cursor(): - create_window = create_new_vm.NewVmDlg(self.qt_app, self.qubes_app, self) + create_window = create_new_vm.NewVmDlg( + self.qt_app, self.qubes_app, self) create_window.exec_() # noinspection PyArgumentList From be39ec86f9a439479d35c5f96de58e1ae1212fdb Mon Sep 17 00:00:00 2001 From: donoban Date: Sat, 10 Apr 2021 18:54:28 +0200 Subject: [PATCH 15/16] Fix main() --- qubesmanager/bootfromdevice.py | 5 +++-- qubesmanager/utils.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index d370131..28830dc 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -24,6 +24,7 @@ from . import ui_bootfromdevice # pylint: disable=no-name-in-module from PyQt5 import QtWidgets, QtGui # pylint: disable=import-error from qubesadmin import tools from qubesadmin import exc +from qubesadmin.tools import qvm_start class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, @@ -168,8 +169,8 @@ def main(args=None): args = parser.parse_args(args) vm = args.domains.pop() - utils.run_synchronous(functools.partial(VMBootFromDeviceWindow, vm)) - + window = utils.run_synchronous(functools.partial(VMBootFromDeviceWindow, vm)) + qvm_start.main(['--cdrom', window.cdrom_location, vm.name]) if __name__ == "__main__": main() diff --git a/qubesmanager/utils.py b/qubesmanager/utils.py index 6b7d828..aa50006 100644 --- a/qubesmanager/utils.py +++ b/qubesmanager/utils.py @@ -564,3 +564,5 @@ def run_synchronous(window_class): qt_app.exec_() qt_app.exit() + + return window From 5558127b6f6a1d30f069abac57c97fcbc2b4acb7 Mon Sep 17 00:00:00 2001 From: donoban Date: Sat, 10 Apr 2021 19:16:12 +0200 Subject: [PATCH 16/16] Add check before launch qvm_start() --- qubesmanager/bootfromdevice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index 28830dc..ddd939e 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -170,7 +170,8 @@ def main(args=None): vm = args.domains.pop() window = utils.run_synchronous(functools.partial(VMBootFromDeviceWindow, vm)) - qvm_start.main(['--cdrom', window.cdrom_location, vm.name]) + if window.result() == 1 and window.cdrom_location is not None: + qvm_start.main(['--cdrom', window.cdrom_location, vm.name]) if __name__ == "__main__": main()