Merge remote-tracking branch 'origin/pr/288'
* origin/pr/288: Add check before launch qvm_start() Fix main() Fix pylint warning Added parent to all __init__() Retored reject() connect Revert "Restored reject() call with ui" Restored reject() call with ui Close dialog after finish qvm_start() Fix pylint warning Fix 'Line too long' Added bootfromdevice dialog to create_new_vm (instead subprocess.call) Removed unneeded reject() definition Use vm.name instead vm object Removed unneded reject() definition Removed qvm_start call from bootfromdevice Improved window size and margins
This commit is contained in:
commit
4420e52d0d
@ -30,8 +30,8 @@ from . import ui_about # pylint: disable=no-name-in-module
|
|||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class AboutDialog(ui_about.Ui_AboutDialog, QDialog):
|
class AboutDialog(ui_about.Ui_AboutDialog, QDialog):
|
||||||
def __init__(self):
|
def __init__(self, parent=None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
@ -40,15 +40,13 @@ class AboutDialog(ui_about.Ui_AboutDialog, QDialog):
|
|||||||
self.release.setText(release_file.read())
|
self.release.setText(release_file.read())
|
||||||
|
|
||||||
self.ok.clicked.connect(self.accept)
|
self.ok.clicked.connect(self.accept)
|
||||||
self.releaseNotes.clicked.connect(on_release_notes_clicked)
|
self.releaseNotes.clicked.connect(self.on_release_notes_clicked)
|
||||||
self.informationNotes.clicked.connect(on_information_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():
|
def on_information_notes_clicked(self):
|
||||||
release_notes_dialog = ReleaseNotesDialog()
|
information_notes_dialog = InformationNotesDialog(self)
|
||||||
release_notes_dialog.exec_()
|
information_notes_dialog.exec_()
|
||||||
|
|
||||||
|
|
||||||
def on_information_notes_clicked():
|
|
||||||
information_notes_dialog = InformationNotesDialog()
|
|
||||||
information_notes_dialog.exec_()
|
|
||||||
|
@ -23,22 +23,24 @@ from . import utils
|
|||||||
from . import ui_bootfromdevice # pylint: disable=no-name-in-module
|
from . import ui_bootfromdevice # pylint: disable=no-name-in-module
|
||||||
from PyQt5 import QtWidgets, QtGui # pylint: disable=import-error
|
from PyQt5 import QtWidgets, QtGui # pylint: disable=import-error
|
||||||
from qubesadmin import tools
|
from qubesadmin import tools
|
||||||
from qubesadmin.tools import qvm_start
|
|
||||||
from qubesadmin import exc
|
from qubesadmin import exc
|
||||||
|
from qubesadmin.tools import qvm_start
|
||||||
|
|
||||||
|
|
||||||
class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
||||||
QtWidgets.QDialog):
|
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)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
self.qapp = qapp
|
self.qapp = qapp
|
||||||
self.qubesapp = qubesapp
|
self.qubesapp = qubesapp
|
||||||
|
self.cdrom_location = None
|
||||||
|
self.new_vm = new_vm
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.setWindowTitle(
|
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.accepted.connect(self.save_and_apply)
|
||||||
self.buttonBox.rejected.connect(self.reject)
|
self.buttonBox.rejected.connect(self.reject)
|
||||||
@ -52,14 +54,11 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
|||||||
self.qapp.setApplicationName(self.tr("Boot Qube From Device"))
|
self.qapp.setApplicationName(self.tr("Boot Qube From Device"))
|
||||||
self.qapp.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
|
self.qapp.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
|
||||||
|
|
||||||
def reject(self):
|
|
||||||
self.done(0)
|
|
||||||
|
|
||||||
def save_and_apply(self):
|
def save_and_apply(self):
|
||||||
if self.blockDeviceRadioButton.isChecked():
|
if self.blockDeviceRadioButton.isChecked():
|
||||||
cdrom_location = self.blockDeviceComboBox.currentText()
|
self.cdrom_location = self.blockDeviceComboBox.currentText()
|
||||||
elif self.fileRadioButton.isChecked():
|
elif self.fileRadioButton.isChecked():
|
||||||
cdrom_location = str(self.fileVM.currentData()) + \
|
self.cdrom_location = str(self.fileVM.currentData()) + \
|
||||||
":" + self.pathText.text()
|
":" + self.pathText.text()
|
||||||
else:
|
else:
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
@ -70,14 +69,14 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
|||||||
|
|
||||||
# warn user if the VM is currently running
|
# warn user if the VM is currently running
|
||||||
self.__warn_if_running__()
|
self.__warn_if_running__()
|
||||||
|
self.accept()
|
||||||
qvm_start.main(['--cdrom', cdrom_location, self.vm.name])
|
|
||||||
|
|
||||||
self.done(0)
|
|
||||||
|
|
||||||
def __warn_if_running__(self):
|
def __warn_if_running__(self):
|
||||||
|
if self.new_vm:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.vm.is_running():
|
if self.qubesapp.domains[self.vm].is_running():
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
self.tr("Warning!"),
|
self.tr("Warning!"),
|
||||||
@ -107,7 +106,8 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
|
|||||||
)
|
)
|
||||||
|
|
||||||
device_choice = []
|
device_choice = []
|
||||||
for domain in self.vm.app.domains:
|
|
||||||
|
for domain in self.qubesapp.domains:
|
||||||
try:
|
try:
|
||||||
for device in domain.devices["block"]:
|
for device in domain.devices["block"]:
|
||||||
device_choice.append((str(device), device))
|
device_choice.append((str(device), device))
|
||||||
@ -169,8 +169,9 @@ def main(args=None):
|
|||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
vm = args.domains.pop()
|
vm = args.domains.pop()
|
||||||
|
|
||||||
utils.run_synchronous(functools.partial(VMBootFromDeviceWindow, vm))
|
window = utils.run_synchronous(functools.partial(VMBootFromDeviceWindow, vm))
|
||||||
|
if window.result() == 1 and window.cdrom_location is not None:
|
||||||
|
qvm_start.main(['--cdrom', window.cdrom_location, vm.name])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -32,6 +32,7 @@ import qubesadmin.tools
|
|||||||
import qubesadmin.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
from . import bootfromdevice
|
||||||
|
|
||||||
from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error
|
from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error
|
||||||
|
|
||||||
@ -102,6 +103,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
|
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.progress = None
|
self.progress = None
|
||||||
|
self.boot_dialog = None
|
||||||
|
|
||||||
utils.initialize_widget_with_labels(
|
utils.initialize_widget_with_labels(
|
||||||
widget=self.label,
|
widget=self.label,
|
||||||
@ -173,14 +175,16 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
self.launch_settings.stateChanged.connect(self.settings_change)
|
self.launch_settings.stateChanged.connect(self.settings_change)
|
||||||
self.install_system.stateChanged.connect(self.install_change)
|
self.install_system.stateChanged.connect(self.install_change)
|
||||||
|
|
||||||
def reject(self):
|
|
||||||
self.done(0)
|
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
vmclass = self.vm_type.currentData()
|
vmclass = self.vm_type.currentData()
|
||||||
|
|
||||||
name = str(self.name.text())
|
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:
|
if name in self.app.domains:
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
@ -229,23 +233,23 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
|
|||||||
self.progress.show()
|
self.progress.show()
|
||||||
|
|
||||||
def create_finished(self):
|
def create_finished(self):
|
||||||
self.progress.hide()
|
|
||||||
|
|
||||||
if self.thread.msg:
|
if self.thread.msg:
|
||||||
QtWidgets.QMessageBox.warning(
|
QtWidgets.QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
self.tr("Error creating the qube!"),
|
self.tr("Error creating the qube!"),
|
||||||
self.tr("ERROR: {0}").format(self.thread.msg))
|
self.tr("ERROR: {0}").format(self.thread.msg))
|
||||||
|
|
||||||
self.done(0)
|
else:
|
||||||
|
|
||||||
if not self.thread.msg:
|
|
||||||
if self.launch_settings.isChecked():
|
if self.launch_settings.isChecked():
|
||||||
subprocess.check_call(['qubes-vm-settings',
|
subprocess.check_call(['qubes-vm-settings',
|
||||||
str(self.name.text())])
|
str(self.name.text())])
|
||||||
if self.install_system.isChecked():
|
if self.install_system.isChecked():
|
||||||
subprocess.check_call(
|
qubesadmin.tools.qvm_start.main(
|
||||||
['qubes-vm-boot-from-device', str(self.name.text())])
|
['--cdrom', self.boot_dialog.cdrom_location,
|
||||||
|
self.name.text()])
|
||||||
|
|
||||||
|
self.progress.hide()
|
||||||
|
self.done(0)
|
||||||
|
|
||||||
def type_change(self):
|
def type_change(self):
|
||||||
template = self.template_vm.currentData()
|
template = self.template_vm.currentData()
|
||||||
|
@ -29,8 +29,8 @@ import subprocess
|
|||||||
class InformationNotesDialog(ui_informationnotes.Ui_InformationNotesDialog,
|
class InformationNotesDialog(ui_informationnotes.Ui_InformationNotesDialog,
|
||||||
QDialog):
|
QDialog):
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
def __init__(self):
|
def __init__(self, parent=None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
details = subprocess.check_output(
|
details = subprocess.check_output(
|
||||||
|
@ -1273,7 +1273,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
|||||||
@pyqtSlot(name='on_action_createvm_triggered')
|
@pyqtSlot(name='on_action_createvm_triggered')
|
||||||
def action_createvm_triggered(self):
|
def action_createvm_triggered(self):
|
||||||
with common_threads.busy_cursor():
|
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_()
|
create_window.exec_()
|
||||||
|
|
||||||
# noinspection PyArgumentList
|
# noinspection PyArgumentList
|
||||||
@ -1519,8 +1520,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
|||||||
try:
|
try:
|
||||||
with common_threads.busy_cursor():
|
with common_threads.busy_cursor():
|
||||||
settings_window = settings.VMSettingsWindow(
|
settings_window = settings.VMSettingsWindow(
|
||||||
vm, init_page=tab, qapp=self.qt_app,
|
vm, tab, self.qt_app, self.qubes_app, self)
|
||||||
qubesapp=self.qubes_app)
|
|
||||||
settings_window.show()
|
settings_window.show()
|
||||||
self.settings_windows[vm.name] = settings_window
|
self.settings_windows[vm.name] = settings_window
|
||||||
except exc.QubesException as ex:
|
except exc.QubesException as ex:
|
||||||
@ -1623,7 +1623,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
|||||||
with common_threads.busy_cursor():
|
with common_threads.busy_cursor():
|
||||||
global_settings_window = global_settings.GlobalSettingsWindow(
|
global_settings_window = global_settings.GlobalSettingsWindow(
|
||||||
self.qt_app,
|
self.qt_app,
|
||||||
self.qubes_app)
|
self.qubes_app,
|
||||||
|
self)
|
||||||
global_settings_window.show()
|
global_settings_window.show()
|
||||||
self.settings_windows['global_settings_window'] = global_settings_window
|
self.settings_windows['global_settings_window'] = global_settings_window
|
||||||
|
|
||||||
@ -1646,7 +1647,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
|||||||
def action_restore_triggered(self):
|
def action_restore_triggered(self):
|
||||||
with common_threads.busy_cursor():
|
with common_threads.busy_cursor():
|
||||||
restore_window = restore.RestoreVMsWindow(self.qt_app,
|
restore_window = restore.RestoreVMsWindow(self.qt_app,
|
||||||
self.qubes_app)
|
self.qubes_app, self)
|
||||||
restore_window.exec_()
|
restore_window.exec_()
|
||||||
|
|
||||||
# noinspection PyArgumentList
|
# noinspection PyArgumentList
|
||||||
@ -1696,7 +1697,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
|
|||||||
# noinspection PyArgumentList
|
# noinspection PyArgumentList
|
||||||
@pyqtSlot(name='on_action_about_qubes_triggered')
|
@pyqtSlot(name='on_action_about_qubes_triggered')
|
||||||
def action_about_qubes_triggered(self): # pylint: disable=no-self-use
|
def action_about_qubes_triggered(self): # pylint: disable=no-self-use
|
||||||
about = AboutDialog()
|
about = AboutDialog(self)
|
||||||
about.exec_()
|
about.exec_()
|
||||||
|
|
||||||
def createPopupMenu(self): # pylint: disable=invalid-name
|
def createPopupMenu(self): # pylint: disable=invalid-name
|
||||||
|
@ -27,8 +27,8 @@ from . import ui_releasenotes # pylint: disable=no-name-in-module
|
|||||||
|
|
||||||
class ReleaseNotesDialog(ui_releasenotes.Ui_ReleaseNotesDialog, QDialog):
|
class ReleaseNotesDialog(ui_releasenotes.Ui_ReleaseNotesDialog, QDialog):
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
def __init__(self):
|
def __init__(self, parent=None):
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
|
@ -30,8 +30,10 @@ import traceback
|
|||||||
from qubesadmin.tools import QubesArgumentParser
|
from qubesadmin.tools import QubesArgumentParser
|
||||||
from qubesadmin import devices
|
from qubesadmin import devices
|
||||||
from qubesadmin import utils as admin_utils
|
from qubesadmin import utils as admin_utils
|
||||||
|
from qubesadmin.tools import qvm_start
|
||||||
import qubesadmin.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
|
from . import bootfromdevice
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import multiselectwidget
|
from . import multiselectwidget
|
||||||
from . import common_threads
|
from . import common_threads
|
||||||
@ -1023,8 +1025,12 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
|
|||||||
self.check_mem_changes()
|
self.check_mem_changes()
|
||||||
|
|
||||||
def boot_from_cdrom_button_pressed(self):
|
def boot_from_cdrom_button_pressed(self):
|
||||||
self.save_and_apply()
|
boot_dialog = bootfromdevice.VMBootFromDeviceWindow(
|
||||||
subprocess.check_call(['qubes-vm-boot-from-device', self.vm.name])
|
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])
|
||||||
|
|
||||||
def virt_mode_changed(self, new_idx): # pylint: disable=unused-argument
|
def virt_mode_changed(self, new_idx): # pylint: disable=unused-argument
|
||||||
self.update_pv_warning()
|
self.update_pv_warning()
|
||||||
|
@ -35,7 +35,7 @@ class TemplateManagerWindow(
|
|||||||
|
|
||||||
def __init__(self, qt_app, qubes_app, dispatcher, parent=None):
|
def __init__(self, qt_app, qubes_app, dispatcher, parent=None):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
super().__init__()
|
super().__init__(parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.qubes_app = qubes_app
|
self.qubes_app = qubes_app
|
||||||
|
@ -564,3 +564,5 @@ def run_synchronous(window_class):
|
|||||||
|
|
||||||
qt_app.exec_()
|
qt_app.exec_()
|
||||||
qt_app.exit()
|
qt_app.exit()
|
||||||
|
|
||||||
|
return window
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>610</width>
|
||||||
<height>170</height>
|
<height>170</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -27,16 +27,34 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Boot qube from device</string>
|
<string>Boot qube from device</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>30</y>
|
<y>30</y>
|
||||||
<width>581</width>
|
<width>581</width>
|
||||||
<height>72</height>
|
<height>74</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalSpacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QRadioButton" name="blockDeviceRadioButton">
|
<widget class="QRadioButton" name="blockDeviceRadioButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Loading…
Reference in New Issue
Block a user