Fixed wildcard imports

Fixed wildcard imports and any further problems resulting from them.
This commit is contained in:
Marta Marczykowska-Górecka 2017-11-06 22:46:35 +01:00
parent eaccc323fb
commit c252e9ec3c
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
8 changed files with 117 additions and 117 deletions

View File

@ -21,11 +21,11 @@
import subprocess
from PyQt4.QtGui import *
import PyQt4.QtGui
# TODO description in tooltip
# TODO icon
class AppListWidgetItem(QListWidgetItem):
class AppListWidgetItem(PyQt4.QtGui.QListWidgetItem):
def __init__(self, name, ident, parent=None):
super(AppListWidgetItem, self).__init__(name, parent)
# self.setToolTip(command)

View File

@ -17,14 +17,16 @@
#
#
import sys
import subprocess
from . import utils
from .firewall import *
from .ui_bootfromdevice import *
from . import firewall
from . import ui_bootfromdevice
from PyQt4 import QtGui, QtCore
import qubesadmin.tools.qvm_start as qvm_start
class VMBootFromDeviceWindow(Ui_BootDialog, QDialog):
class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog, QtGui.QDialog):
def __init__(self, vm, qapp, parent=None):
super(VMBootFromDeviceWindow, self).__init__(parent)
@ -34,8 +36,8 @@ class VMBootFromDeviceWindow(Ui_BootDialog, QDialog):
self.setupUi(self)
self.setWindowTitle(self.tr("Boot {vm} from device").format(vm=self.vm.name))
self.connect(self.buttonBox, SIGNAL("accepted()"), self.save_and_apply)
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
self.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.save_and_apply)
self.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject)
# populate buttons and such
self.__init_buttons__()
@ -50,7 +52,7 @@ class VMBootFromDeviceWindow(Ui_BootDialog, QDialog):
elif self.fileRadioButton.isChecked():
cdrom_location = str(self.vm_list[self.fileVM.currentIndex()]) + ":" + self.pathText.text()
else:
QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr(
"ERROR!"),
self.tr("No file or block device selected; please select one."))
@ -102,7 +104,7 @@ class VMBootFromDeviceWindow(Ui_BootDialog, QDialog):
self.pathText.setText(new_path)
parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs=1)
parser = firewall.qubesadmin.tools.QubesArgumentParser(vmname_nargs=1)
def main(args=None):
global bootfromdevice_window
@ -110,7 +112,7 @@ def main(args=None):
args = parser.parse_args(args)
vm = args.domains.pop()
qapp = QApplication(sys.argv)
qapp = QtGui.QApplication(sys.argv)
qapp.setOrganizationName('Invisible Things Lab')
qapp.setOrganizationDomain("https://www.qubes-os.org/")
qapp.setApplicationName("Qubes VM Settings")

View File

@ -26,8 +26,7 @@ import threading
import time
import subprocess
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui
import qubesadmin
import qubesadmin.tools
@ -38,7 +37,7 @@ from .ui_newappvmdlg import Ui_NewVMDlg
from .thread_monitor import ThreadMonitor
class NewVmDlg(QDialog, Ui_NewVMDlg):
class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg):
def __init__(self, qtapp, app, parent = None):
super(NewVmDlg, self).__init__(parent)
self.setupUi(self)
@ -69,13 +68,13 @@ class NewVmDlg(QDialog, Ui_NewVMDlg):
(lambda vm: vm.provides_network),
allow_internal=False, allow_default=True, allow_none=True)
self.name.setValidator(QRegExpValidator(
QRegExp("[a-zA-Z0-9-]*", Qt.CaseInsensitive), None))
self.name.setValidator(QtGui.QRegExpValidator(
QtCore.QRegExp("[a-zA-Z0-9-]*", QtCore.Qt.CaseInsensitive), None))
self.name.selectAll()
self.name.setFocus()
if len(self.template_list) == 0:
QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr('No template available!'),
self.tr('Cannot create a qube when no template exists.'))
@ -103,7 +102,7 @@ class NewVmDlg(QDialog, Ui_NewVMDlg):
except LookupError:
pass
else:
QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr('Incorrect qube name!'),
self.tr('A qube with the name <b>{}</b> already exists in the '
'system!').format(name))
@ -128,7 +127,7 @@ class NewVmDlg(QDialog, Ui_NewVMDlg):
thread.daemon = True
thread.start()
progress = QProgressDialog(
progress = QtGui.QProgressDialog(
self.tr("Creating new qube <b>{}</b>...").format(name), "", 0, 0)
progress.setCancelButton(None)
progress.setModal(True)
@ -141,7 +140,7 @@ class NewVmDlg(QDialog, Ui_NewVMDlg):
progress.hide()
if not thread_monitor.success:
QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("Error creating the qube!"),
self.tr("ERROR: {}").format(thread_monitor.error_msg))
@ -214,7 +213,7 @@ parser = qubesadmin.tools.QubesArgumentParser()
def main(args=None):
args = parser.parse_args(args)
qtapp = QApplication(sys.argv)
qtapp = QtGui.QApplication(sys.argv)
qtapp.setOrganizationName('Invisible Things Lab')
qtapp.setOrganizationDomain('https://www.qubes-os.org/')
qtapp.setApplicationName('Create qube')

View File

@ -21,9 +21,7 @@
import datetime
import re
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui
import qubesadmin.firewall
from . import ui_newfwruledlg
@ -32,7 +30,7 @@ from . import ui_newfwruledlg
class FirewallModifiedOutsideError(ValueError):
pass
class QIPAddressValidator(QValidator):
class QIPAddressValidator(QtGui.QValidator):
def __init__(self, parent = None):
super (QIPAddressValidator, self).__init__(parent)
@ -40,10 +38,10 @@ class QIPAddressValidator(QValidator):
hostname = str(input)
if len(hostname) > 255 or len(hostname) == 0:
return (QValidator.Intermediate, input, pos)
return (QtGui.QValidator.Intermediate, input, pos)
if hostname == "*":
return (QValidator.Acceptable, input, pos)
return (QtGui.QValidator.Acceptable, input, pos)
unmask = hostname.split("/", 1)
if len(unmask) == 2:
@ -51,27 +49,27 @@ class QIPAddressValidator(QValidator):
mask = unmask[1]
if mask.isdigit() or mask == "":
if re.match("^([0-9]{1,3}\.){3}[0-9]{1,3}$", hostname) is None:
return (QValidator.Invalid, input, pos)
return (QtGui.QValidator.Invalid, input, pos)
if mask != "":
mask = int(unmask[1])
if mask < 0 or mask > 32:
return (QValidator.Invalid, input, pos)
return (QtGui.QValidator.Invalid, input, pos)
else:
return (QValidator.Invalid, input, pos)
return (QtGui.QValidator.Invalid, input, pos)
if hostname[-1:] == ".":
hostname = hostname[:-1]
if hostname[-1:] == "-":
return (QValidator.Intermediate, input, pos)
return (QtGui.QValidator.Intermediate, input, pos)
allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
if all(allowed.match(x) for x in hostname.split(".")):
return (QValidator.Acceptable, input, pos)
return (QtGui.QValidator.Acceptable, input, pos)
return (QValidator.Invalid, input, pos)
return (QtGui.QValidator.Invalid, input, pos)
class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
class NewFwRuleDlg (QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
def __init__(self, parent = None):
super (NewFwRuleDlg, self).__init__(parent)
self.setupUi(self)
@ -79,20 +77,20 @@ class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
self.set_ok_enabled(False)
self.addressComboBox.setValidator(QIPAddressValidator())
self.addressComboBox.editTextChanged.connect(self.address_editing_finished)
self.serviceComboBox.setValidator(QRegExpValidator(QRegExp("[a-z][a-z0-9-]+|[0-9]+(-[0-9]+)?", Qt.CaseInsensitive), None))
self.serviceComboBox.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp("[a-z][a-z0-9-]+|[0-9]+(-[0-9]+)?", QtCore.Qt.CaseInsensitive), None))
self.serviceComboBox.setEnabled(False)
self.serviceComboBox.setInsertPolicy(QComboBox.InsertAtBottom)
self.serviceComboBox.setInsertPolicy(QtGui.QComboBox.InsertAtBottom)
self.populate_combos()
self.serviceComboBox.setInsertPolicy(QComboBox.InsertAtTop)
self.serviceComboBox.setInsertPolicy(QtGui.QComboBox.InsertAtTop)
def accept(self):
if self.tcp_radio.isChecked() or self.udp_radio.isChecked():
if len(self.serviceComboBox.currentText()) == 0:
msg = QMessageBox()
msg = QtGui.QMessageBox()
msg.warning(self, self.tr("Firewall rule"),
self.tr("You need to fill service name/port for TCP/UDP rule"))
return
QDialog.accept(self)
QtGui.QDialog.accept(self)
def populate_combos(self):
example_addresses = [
@ -118,7 +116,7 @@ class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
self.set_ok_enabled(True)
def set_ok_enabled(self, on):
ok_button = self.buttonBox.button(QDialogButtonBox.Ok)
ok_button = self.buttonBox.button(QtGui.QDialogButtonBox.Ok)
if ok_button is not None:
ok_button.setEnabled(on)
@ -134,9 +132,9 @@ class NewFwRuleDlg (QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
if checked:
self.serviceComboBox.setEnabled(False)
class QubesFirewallRulesModel(QAbstractItemModel):
class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
def __init__(self, parent=None):
QAbstractItemModel.__init__(self, parent)
QtCore.QAbstractItemModel.__init__(self, parent)
self.__columnNames = {0: "Address", 1: "Service", 2: "Protocol", }
self.__services = list()
@ -154,7 +152,7 @@ class QubesFirewallRulesModel(QAbstractItemModel):
def sort(self, idx, order):
from operator import attrgetter
rev = (order == Qt.AscendingOrder)
rev = (order == QtCore.Qt.AscendingOrder)
self.children.sort(key = lambda x: self.get_column_string(idx, x)
, reverse = rev)
@ -362,7 +360,7 @@ class QubesFirewallRulesModel(QAbstractItemModel):
try:
rule.dsthost = address
except ValueError:
QMessageBox.warning(None, self.tr("Invalid address"),
QtGui.QMessageBox.warning(None, self.tr("Invalid address"),
self.tr("Address '{0}' is invalid.").format(address))
if dialog.tcp_radio.isChecked():
@ -374,7 +372,7 @@ class QubesFirewallRulesModel(QAbstractItemModel):
try:
rule.dstports = service
except ValueError:
QMessageBox.warning(None, self.tr("Invalid port or service"),
QtGui.QMessageBox.warning(None, self.tr("Invalid port or service"),
self.tr("Port number or service '{0}' is invalid.")
.format(service))
elif service is not None:
@ -384,7 +382,7 @@ class QubesFirewallRulesModel(QAbstractItemModel):
if self.get_service_port(service) is not None:
rule.dstports = self.get_service_port(service)
else:
QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("Invalid port or service"),
self.tr("Port number or service '{0}' is invalid.")
.format(service))
@ -394,36 +392,36 @@ class QubesFirewallRulesModel(QAbstractItemModel):
else:
self.appendChild(rule)
def index(self, row, column, parent=QModelIndex()):
def index(self, row, column, parent=QtCore.QModelIndex()):
if not self.hasIndex(row, column, parent):
return QModelIndex()
return QtCore.QModelIndex()
return self.createIndex(row, column, self.children[row])
def parent(self, child):
return QModelIndex()
return QtCore.QModelIndex()
def rowCount(self, parent=QModelIndex()):
def rowCount(self, parent=QtCore.QModelIndex()):
return len(self)
def columnCount(self, parent=QModelIndex()):
def columnCount(self, parent=QtCore.QModelIndex()):
return len(self.__columnNames)
def hasChildren(self, index=QModelIndex()):
def hasChildren(self, index=QtCore.QModelIndex()):
parentItem = index.internalPointer()
if parentItem is not None:
return False
else:
return True
def data(self, index, role=Qt.DisplayRole):
if index.isValid() and role == Qt.DisplayRole:
def data(self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and role == QtCore.Qt.DisplayRole:
return self.get_column_string(index.column()
,self.children[index.row()])
def headerData(self, section, orientation, role=Qt.DisplayRole):
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if section < len(self.__columnNames) \
and orientation == Qt.Horizontal and role == Qt.DisplayRole:
and orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
return self.__columnNames[section]
@property
@ -432,7 +430,7 @@ class QubesFirewallRulesModel(QAbstractItemModel):
def appendChild(self, child):
row = len(self)
self.beginInsertRows(QModelIndex(), row, row)
self.beginInsertRows(QtCore.QModelIndex(), row, row)
self.children.append(child)
self.endInsertRows()
index = self.createIndex(row, 0, child)
@ -443,7 +441,7 @@ class QubesFirewallRulesModel(QAbstractItemModel):
if i >= len(self):
return
self.beginRemoveRows(QModelIndex(), i, i)
self.beginRemoveRows(QtCore.QModelIndex(), i, i)
del self.children[i]
self.endRemoveRows()
index = self.createIndex(i, 0)

View File

@ -22,20 +22,19 @@
import sys
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui
from qubesadmin import Qubes
from qubesadmin.utils import parse_size, updates_vms_status
from .ui_globalsettingsdlg import *
from . import ui_globalsettingsdlg
from configparser import ConfigParser
from qubesadmin.utils import parse_size, updates_vms_status
qmemman_config_path = '/etc/qubes/qmemman.conf'
class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, QtGui.QDialog):
def __init__(self, app, qvm_collection, parent=None):
super(GlobalSettingsWindow, self).__init__(parent)
@ -45,9 +44,9 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
self.setupUi(self)
self.connect(self.buttonBox, SIGNAL("accepted()"), self.save_and_apply)
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
self.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.save_and_apply)
self.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject)
self.__init_system_defaults__()
self.__init_kernel_defaults__()
self.__init_mem_defaults__()
@ -251,7 +250,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
self.updates_dom0.setChecked(self.updates_dom0_val)
updates_vms = updates_vms_status(self.qvm_collection)
if updates_vms is None:
self.updates_vm.setCheckState(Qt.PartiallyChecked)
self.updates_vm.setCheckState(QtCore.Qt.PartiallyChecked)
else:
self.updates_vm.setCheckState(updates_vms)
@ -259,7 +258,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
if self.updates_dom0.isChecked() != self.updates_dom0_val:
# TODO updates_dom0_toggle(self.qvm_collection, self.updates_dom0.isChecked())
raise NotImplementedError('Toggle dom0 updates not implemented')
if self.updates_vm.checkState() != Qt.PartiallyChecked:
if self.updates_vm.checkState() != QtCore.Qt.PartiallyChecked:
for vm in self.qvm_collection.domains:
vm.features['check-updates'] = bool(self.updates_vm.checkState())
@ -286,18 +285,18 @@ def handle_exception( exc_type, exc_value, exc_traceback ):
filename = os.path.basename( filename )
error = "%s: %s" % ( exc_type.__name__, exc_value )
QMessageBox.critical(None, "Houston, we have a problem...",
QtGui.QMessageBox.critical(None, "Houston, we have a problem...",
"Whoops. A critical error has occured. This is most likely a bug "
"in Qubes Global Settings application.<br><br>"
"<b><i>%s</i></b>" % error +
"at <b>line %d</b> of file <b>%s</b>.<br/><br/>"
% ( line, filename ))
% ( line, filename ))
def main():
global qtapp
qtapp = QApplication(sys.argv)
qtapp = QtGui.QApplication(sys.argv)
qtapp.setOrganizationName("The Qubes Project")
qtapp.setOrganizationDomain("http://qubes-os.org")
qtapp.setApplicationName("Qubes Global Settings")

View File

@ -1,8 +1,7 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from .ui_multiselectwidget import *
from PyQt4 import QtCore, QtGui
from . import ui_multiselectwidget
class MultiSelectWidget(Ui_MultiSelectWidget, QWidget):
class MultiSelectWidget(ui_multiselectwidget.Ui_MultiSelectWidget, QtGui.QWidget):
__pyqtSignals__ = ("selected_changed()",)
__pyqtSignals__ = ("items_added(PyQt_PyObject)",)
@ -15,8 +14,8 @@ class MultiSelectWidget(Ui_MultiSelectWidget, QWidget):
self.add_all_button.clicked.connect(self.add_all)
self.remove_selected_button.clicked.connect(self.remove_selected)
self.remove_all_button.clicked.connect(self.remove_all)
self.available_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.selected_list.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.available_list.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.selected_list.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
def switch_selected(self, src, dst):
selected = src.selectedItems()
@ -28,11 +27,11 @@ class MultiSelectWidget(Ui_MultiSelectWidget, QWidget):
dst.addItem(item)
items.append(item)
dst.sortItems()
self.emit(SIGNAL("selected_changed()"))
self.emit(QtCore.SIGNAL("selected_changed()"))
if src is self.selected_list:
self.emit(SIGNAL("items_removed(PyQt_PyObject)"), items)
self.emit(QtCore.SIGNAL("items_removed(PyQt_PyObject)"), items)
else:
self.emit(SIGNAL("items_added(PyQt_PyObject)"), items)
self.emit(QtCore.SIGNAL("items_added(PyQt_PyObject)"), items)
def add_selected(self):
self.switch_selected(self.available_list, self.selected_list)
@ -47,11 +46,11 @@ class MultiSelectWidget(Ui_MultiSelectWidget, QWidget):
dst.addItem(item)
items.append(item)
dst.sortItems()
self.emit(SIGNAL("selected_changed()"))
self.emit(QtCore.SIGNAL("selected_changed()"))
if src is self.selected_list:
self.emit(SIGNAL("items_removed(PyQt_PyObject)"), items)
self.emit(QtCore.SIGNAL("items_removed(PyQt_PyObject)"), items)
else:
self.emit(SIGNAL("items_added(PyQt_PyObject)"), items)
self.emit(QtCore.SIGNAL("items_added(PyQt_PyObject)"), items)
def add_all(self):

View File

@ -28,7 +28,9 @@ import subprocess
import threading
import time
import traceback
import os
import sys
from qubesadmin.tools import QubesArgumentParser
from . import utils
from . import multiselectwidget
@ -36,10 +38,11 @@ from . import thread_monitor
from .appmenu_select import AppmenuSelectManager
from . import firewall
from PyQt4 import QtCore, QtGui
from . import ui_settingsdlg
class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
tabs_indices = collections.OrderedDict((
('basic', 0),
('advanced', 1),
@ -66,8 +69,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
assert (idx in range(self.tabWidget.count()))
self.tabWidget.setCurrentIndex(idx)
self.connect(self.buttonBox, firewall.SIGNAL("accepted()"), self.save_and_apply)
self.connect(self.buttonBox, firewall.SIGNAL("rejected()"), self.reject)
self.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.save_and_apply)
self.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject)
self.tabWidget.currentChanged.connect(self.current_tab_changed)
@ -83,8 +86,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
###### advanced tab
self.__init_advanced_tab__()
self.include_in_balancing.stateChanged.connect(self.include_in_balancing_state_changed)
self.connect(self.init_mem, firewall.SIGNAL("editingFinished()"), self.check_mem_changes)
self.connect(self.max_mem_size, firewall.SIGNAL("editingFinished()"), self.check_mem_changes)
self.connect(self.init_mem, QtCore.SIGNAL("editingFinished()"), self.check_mem_changes)
self.connect(self.max_mem_size, QtCore.SIGNAL("editingFinished()"), self.check_mem_changes)
self.bootFromDeviceButton.clicked.connect(self.boot_from_cdrom_button_pressed)
###### firewall tab
@ -105,7 +108,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
####### devices tab
self.__init_devices_tab__()
self.connect(self.dev_list, firewall.SIGNAL("selected_changed()"), self.devices_selection_changed)
self.connect(self.dev_list, QtCore.SIGNAL("selected_changed()"), self.devices_selection_changed)
####### services tab
self.__init_services_tab__()
@ -132,7 +135,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
thread.daemon = True
thread.start()
progress = firewall.QProgressDialog(
progress = QtGui.QProgressDialog(
self.tr("Applying settings to <b>{0}</b>...").format(self.vm.name), "", 0, 0)
progress.setCancelButton(None)
progress.setModal(True)
@ -145,7 +148,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
progress.hide()
if not t_monitor.success:
firewall.QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("Error while changing settings for {0}!").format(self.vm.name),
self.tr("ERROR: {0}").format(t_monitor.error_msg))
@ -201,7 +204,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
netvm = self.vm.netvm
if netvm is not None and \
not netvm.features.check_with_template('qubes-firewall', False):
firewall.QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("VM configuration problem!"),
self.tr("The '{vm}' AppVM is network connected to "
"'{netvm}', which does not support firewall!<br/>"
@ -227,7 +230,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def __init_basic_tab__(self):
self.vmname.setText(self.vm.name)
self.vmname.setValidator(firewall.QRegExpValidator(firewall.QRegExp("[a-zA-Z0-9-]*", firewall.Qt.CaseInsensitive), None))
self.vmname.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp("[a-zA-Z0-9-]*", QtCore.Qt.CaseInsensitive), None))
self.vmname.setEnabled(False)
self.rename_vm_button.setEnabled(not self.vm.is_running())
self.delete_vm_button.setEnabled(not self.vm.is_running())
@ -385,14 +388,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def check_mem_changes(self):
if self.max_mem_size.value() < self.init_mem.value():
firewall.QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("Warning!"),
self.tr("Max memory can not be less than initial memory.<br>"
"Setting max memory to equal initial memory."))
self.max_mem_size.setValue(self.init_mem.value())
# Linux specific limit: init memory must not be below max_mem_size/10.79 in order to allow scaling up to max_mem_size (or else "add_memory() failed: -17" problem)
if self.init_mem.value() * 10 < self.max_mem_size.value():
firewall.QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("Warning!"),
self.tr("Initial memory can not be less than one tenth "
"Max memory.<br>Setting initial memory to the minimum "
@ -410,7 +413,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
time.sleep(0.1)
if not t_monitor.success:
firewall.QMessageBox.warning(None,
QtGui.QMessageBox.warning(None,
self.tr("Error!"),
self.tr("ERROR: {}").format(
t_monitor.error_msg))
@ -429,7 +432,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def rename_vm(self):
new_vm_name, ok = firewall.QInputDialog.getText(self,
new_vm_name, ok = QtGui.QInputDialog.getText(self,
self.tr('Rename VM'),
self.tr('New name: (WARNING: '
'all other changes will be discarded)'))
@ -449,7 +452,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def remove_vm(self):
answer, ok = firewall.QInputDialog.getText(
answer, ok = QtGui.QInputDialog.getText(
self,
self.tr('Delete VM'),
self.tr('Are you absolutely sure you want to delete this VM? '
@ -463,7 +466,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
self.done(0)
elif ok:
firewall.QMessageBox.warning(
QtGui.QMessageBox.warning(
None,
self.tr("Removal cancelled"),
self.tr("The VM will not be removed."))
@ -479,14 +482,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def clone_vm(self):
cloned_vm_name, ok = firewall.QInputDialog.getText(
cloned_vm_name, ok = QtGui.QInputDialog.getText(
self,
self.tr('Clone VM'),
self.tr('Name for the cloned VM:'))
if ok:
self._run_in_thread(self._clone_vm, cloned_vm_name)
firewall.QMessageBox.warning(
QtGui.QMessageBox.warning(
None,
self.tr("Success"),
self.tr("The VM was cloned successfully."))
@ -593,7 +596,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
for dev in lspci.splitlines():
devs.append((dev.rstrip(), dev.split(' ')[0]))
class DevListWidgetItem(firewall.QListWidgetItem):
class DevListWidgetItem(QtGui.QListWidgetItem):
def __init__(self, name, ident, parent = None):
super(DevListWidgetItem, self).__init__(name, parent)
self.ident = ident
@ -727,22 +730,22 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
if not feature.startswith('service.'):
continue
service = feature[len('service.'):]
item = firewall.QListWidgetItem(service)
item = QtGui.QListWidgetItem(service)
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked
if self.vm.features[feature] else ui_settingsdlg.QtCore.Qt.Unchecked)
self.services_list.addItem(item)
self.new_srv_dict[service] = self.vm.features[feature]
self.connect(self.services_list, firewall.SIGNAL("itemClicked(QListWidgetItem *)"), self.services_item_clicked)
self.connect(self.services_list, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.services_item_clicked)
def __add_service__(self):
srv = str(self.service_line_edit.text()).strip()
if srv != "":
if srv in self.new_srv_dict:
firewall.QMessageBox.information(None, '',
QtGui.QMessageBox.information(None, '',
self.tr('Service already on the list!'))
else:
item = firewall.QListWidgetItem(srv)
item = QtGui.QListWidgetItem(srv)
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked)
self.services_list.addItem(item)
self.new_srv_dict[srv] = True
@ -753,7 +756,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
if not item:
return
if str(item.text()) == 'meminfo-writer':
firewall.QMessageBox.information(None,
QtGui.QMessageBox.information(None,
self.tr('Service can not be removed'),
self.tr('Service meminfo-writer can not be removed from the list.'))
return
@ -812,8 +815,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def set_fw_model(self, model):
self.fw_model = model
self.rulesTreeView.setModel(model)
self.rulesTreeView.header().setResizeMode(firewall.QHeaderView.ResizeToContents)
self.rulesTreeView.header().setResizeMode(0, firewall.QHeaderView.Stretch)
self.rulesTreeView.header().setResizeMode(QtGui.QHeaderView.ResizeToContents)
self.rulesTreeView.header().setResizeMode(0, QtGui.QHeaderView.Stretch)
self.set_allow(model.allow)
if model.tempFullAccessExpireTime:
self.tempFullAccess.setChecked(True)
@ -874,7 +877,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
def handle_exception(exc_type, exc_value, exc_traceback):
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
filename = firewall.os.path.basename(filename)
filename = os.path.basename(filename)
error = "%s: %s" % (exc_type.__name__, exc_value)
strace = ""
@ -887,9 +890,9 @@ def handle_exception(exc_type, exc_value, exc_traceback):
strace += "line no.: %d\n" %line
strace += "file: %s\n" %filename
msg_box = firewall.QMessageBox()
msg_box = QtGui.QMessageBox()
msg_box.setDetailedText(strace)
msg_box.setIcon(firewall.QMessageBox.Critical)
msg_box.setIcon(QtGui.QMessageBox.Critical)
msg_box.setWindowTitle("Houston, we have a problem...")
msg_box.setText("Whoops. A critical error has occured. This is most likely a bug "
"in Qubes Manager.<br><br>"
@ -900,7 +903,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
msg_box.exec_()
parser = firewall.qubesadmin.tools.QubesArgumentParser(vmname_nargs=1)
parser = QubesArgumentParser(vmname_nargs=1)
parser.add_argument('--tab', metavar='TAB',
action='store',
@ -916,13 +919,13 @@ def main(args=None):
args = parser.parse_args(args)
vm = args.domains.pop()
qapp = firewall.QApplication(firewall.sys.argv)
qapp = QtGui.QApplication(sys.argv)
qapp.setOrganizationName('Invisible Things Lab')
qapp.setOrganizationDomain("https://www.qubes-os.org/")
qapp.setApplicationName("Qubes VM Settings")
if not utils.is_debug():
firewall.sys.excepthook = handle_exception
sys.excepthook = handle_exception
settings_window = VMSettingsWindow(vm, qapp, args.tab)
settings_window.show()

View File

@ -20,11 +20,11 @@
#
from PyQt4.QtCore import *
import PyQt4.QtCore
import threading
class ThreadMonitor(QObject):
class ThreadMonitor(PyQt4.QtCore.QObject):
def __init__(self):
self.success = True
self.error_msg = None