diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index f14ab4c..5477c30 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -38,7 +38,7 @@ from .thread_monitor import ThreadMonitor class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): - def __init__(self, qtapp, app, parent = None): + def __init__(self, qtapp, app, parent=None): super(NewVmDlg, self).__init__(parent) self.setupUi(self) @@ -137,7 +137,7 @@ class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): while not thread_monitor.is_finished(): self.qtapp.processEvents() - time.sleep (0.1) + time.sleep(0.1) progress.hide() diff --git a/qubesmanager/firewall.py b/qubesmanager/firewall.py index 07f5847..d56a2ce 100644 --- a/qubesmanager/firewall.py +++ b/qubesmanager/firewall.py @@ -31,8 +31,8 @@ class FirewallModifiedOutsideError(ValueError): pass class QIPAddressValidator(QtGui.QValidator): - def __init__(self, parent = None): - super (QIPAddressValidator, self).__init__(parent) + def __init__(self, parent=None): + super(QIPAddressValidator, self).__init__(parent) def validate(self, input, pos): hostname = str(input) @@ -69,9 +69,9 @@ class QIPAddressValidator(QtGui.QValidator): return (QtGui.QValidator.Invalid, input, pos) -class NewFwRuleDlg (QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg): - def __init__(self, parent = None): - super (NewFwRuleDlg, self).__init__(parent) +class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg): + def __init__(self, parent=None): + super(NewFwRuleDlg, self).__init__(parent) self.setupUi(self) self.set_ok_enabled(False) @@ -105,8 +105,8 @@ class NewFwRuleDlg (QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg): displayed_services = [ '', 'http', 'https', 'ftp', 'ftps', 'smtp', - 'smtps', 'pop3', 'pop3s', 'imap', 'imaps', 'odmr', - 'nntp', 'nntps', 'ssh', 'telnet', 'telnets', 'ntp', + 'smtps', 'pop3', 'pop3s', 'imap', 'imaps', 'odmr', + 'nntp', 'nntps', 'ssh', 'telnet', 'telnets', 'ntp', 'snmp', 'ldap', 'ldaps', 'irc', 'ircs', 'xmpp-client', 'syslog', 'printer', 'nfs', 'x11', '1024-1234' @@ -151,7 +151,7 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): if match is not None: service = match.groupdict() self.__services.append( - (service["name"], int(service["port"]),) ) + (service["name"], int(service["port"]),)) f.close() self.fw_changed = False @@ -160,8 +160,8 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): from operator import attrgetter rev = (order == QtCore.Qt.AscendingOrder) - self.children.sort(key = lambda x: self.get_column_string(idx, x) - , reverse = rev) + self.children.sort(key=lambda x: self.get_column_string(idx, x) + , reverse=rev) index1 = self.createIndex(0, 0) index2 = self.createIndex(len(self)-1, len(self.__columnNames)-1) @@ -295,7 +295,7 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): action='accept')) else: rules.append(qubesadmin.firewall.Rule(None, - action = 'drop')) + action='drop')) vm.firewall.rules = rules @@ -324,14 +324,14 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): (self.tempFullAccessExpireTime != 0) != tempFullAccess: self.fw_changed = True - conf = { "allow": allow, + conf = {"allow": allow, "rules": list() } conf['rules'].extend(self.children) if tempFullAccess and not allow: - conf["rules"].append(qubesadmin.firewall.Rule(None,action='accept' + conf["rules"].append(qubesadmin.firewall.Rule(None, action='accept' , expire=int(datetime.datetime.now().strftime("%s"))+\ tempFullAccessTime*60)) @@ -355,13 +355,13 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): else: dialog.any_radio.setChecked(True) - def run_rule_dialog(self, dialog, row = None): + def run_rule_dialog(self, dialog, row=None): if dialog.exec_(): address = str(dialog.addressComboBox.currentText()) service = str(dialog.serviceComboBox.currentText()) - rule = qubesadmin.firewall.Rule(None,action='accept') + rule = qubesadmin.firewall.Rule(None, action='accept') if address is not None and address != "*": try: @@ -425,8 +425,8 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel): 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()]) + return self.get_column_string(index.column(), + self.children[index.row()]) def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole): if section < len(self.__columnNames) \ diff --git a/qubesmanager/global_settings.py b/qubesmanager/global_settings.py index cf1f4f7..7b27ed6 100644 --- a/qubesmanager/global_settings.py +++ b/qubesmanager/global_settings.py @@ -44,7 +44,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, self.qvm_collection = qvm_collection self.setupUi(self) - + self.connect( self.buttonBox, QtCore.SIGNAL("accepted()"), @@ -125,7 +125,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, updatevm_name = str(self.update_vm_combo.currentText()) updatevm_name = updatevm_name.split(' ')[0] updatevm = self.qvm_collection.domains[updatevm_name] - + self.qvm_collection.updatevm = updatevm #clockvm @@ -133,7 +133,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, clockvm_name = str(self.clock_vm_combo.currentText()) clockvm_name = clockvm_name.split(' ')[0] clockvm = self.qvm_collection.domains[clockvm_name] - + self.qvm_collection.clockvm = clockvm #default netvm @@ -141,7 +141,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, name = str(self.default_netvm_combo.currentText()) name = name.split(' ')[0] vm = self.qvm_collection.domains[name] - + self.qvm_collection.default_netvm = vm #default template @@ -149,7 +149,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, name = str(self.default_template_combo.currentText()) name = name.split(' ')[0] vm = self.qvm_collection.domains[name] - + self.qvm_collection.default_template = vm @@ -174,17 +174,17 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, if self.default_kernel_combo.currentIndex() != self.kernel_idx: kernel = str(self.default_kernel_combo.currentText()) kernel = kernel.split(' ')[0] - + self.qvm_collection.default_kernel = kernel - + def __init_mem_defaults__(self): #qmemman settings self.qmemman_config = ConfigParser() - self.vm_min_mem_val = '200MiB' #str(qmemman_algo.MIN_PREFMEM) + self.vm_min_mem_val = '200MiB' #str(qmemman_algo.MIN_PREFMEM) self.dom0_mem_boost_val = '350MiB' #str(qmemman_algo.DOM0_MEM_BOOST) - + self.qmemman_config.read(qmemman_config_path) if self.qmemman_config.has_section('global'): self.vm_min_mem_val = \ @@ -230,7 +230,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, #If there already is a 'global' section, we don't use # SafeConfigParser.write() - it would get rid of # all the comments... - + lines_to_add = {} lines_to_add['vm-min-mem'] = \ "vm-min-mem = " + current_min_vm_mem + "\n" @@ -249,7 +249,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, del lines_to_add['dom0-mem-boost'] else: config_lines.append(l) - + qmemman_config_file.close() for l in lines_to_add: @@ -286,7 +286,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, def save_and_apply(self): - self.__apply_system_defaults__() + self.__apply_system_defaults__() self.__apply_kernel_defaults__() self.__apply_mem_defaults__() self.__apply_updates__() @@ -296,13 +296,13 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings, # Bases on the original code by: # Copyright (c) 2002-2007 Pascal Varet -def handle_exception( exc_type, exc_value, exc_traceback ): +def handle_exception(exc_type, exc_value, exc_traceback): import os.path import traceback - filename, line, dummy, dummy = traceback.extract_tb( exc_traceback ).pop() - filename = os.path.basename( filename ) - error = "%s: %s" % ( exc_type.__name__, exc_value ) + filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop() + filename = os.path.basename(filename) + error = "%s: %s" % (exc_type.__name__, exc_value) QtGui.QMessageBox.critical( None, @@ -310,7 +310,7 @@ def handle_exception( exc_type, exc_value, exc_traceback ): "Whoops. A critical error has occured. This is most likely a bug " "in Qubes Global Settings application.

%s" % error + "at line %d of file %s.

" - % ( line, filename )) + % (line, filename)) def main(): diff --git a/qubesmanager/multiselectwidget.py b/qubesmanager/multiselectwidget.py index 57d640c..ca843d7 100644 --- a/qubesmanager/multiselectwidget.py +++ b/qubesmanager/multiselectwidget.py @@ -31,7 +31,7 @@ class MultiSelectWidget( items.append(item) dst.sortItems() self.emit(QtCore.SIGNAL("selected_changed()")) - if src is self.selected_list: + if src is self.selected_list: self.emit(QtCore.SIGNAL("items_removed(PyQt_PyObject)"), items) else: self.emit(QtCore.SIGNAL("items_added(PyQt_PyObject)"), items) @@ -40,8 +40,8 @@ class MultiSelectWidget( self.switch_selected(self.available_list, self.selected_list) def remove_selected(self): - self.switch_selected(self.selected_list, self.available_list) - + self.switch_selected(self.selected_list, self.available_list) + def move_all(self, src, dst): items = [] while src.count() > 0: @@ -50,7 +50,7 @@ class MultiSelectWidget( items.append(item) dst.sortItems() self.emit(QtCore.SIGNAL("selected_changed()")) - if src is self.selected_list: + if src is self.selected_list: self.emit(QtCore.SIGNAL("items_removed(PyQt_PyObject)"), items) else: self.emit(QtCore.SIGNAL("items_added(PyQt_PyObject)"), items) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 4c29a5b..d865ba9 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -157,7 +157,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): while not t_monitor.is_finished(): self.qapp.processEvents() - time.sleep (0.1) + time.sleep(0.1) progress.hide() @@ -209,7 +209,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): except Exception as ex: ret += [self.tr("Applications tab:"), str(ex)] - if len(ret) > 0 : + if len(ret) > 0: t_monitor.set_error_msg('\n'.join(ret)) utils.debug('\n'.join(ret)) @@ -626,7 +626,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): devs.append((dev.rstrip(), dev.split(' ')[0])) class DevListWidgetItem(QtGui.QListWidgetItem): - def __init__(self, name, ident, parent = None): + def __init__(self, name, ident, parent=None): super(DevListWidgetItem, self).__init__(name, parent) self.ident = ident self.Type @@ -688,7 +688,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): return msg def include_in_balancing_state_changed(self, state): - for r in range (self.services_list.count()): + for r in range(self.services_list.count()): item = self.services_list.item(r) if str(item.text()) == 'meminfo-writer': item.setCheckState(state) @@ -705,7 +705,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): def devices_selection_changed(self): if self.include_in_balancing.isChecked(): - if self.dev_list.selected_list.count() > 0 : + if self.dev_list.selected_list.count() > 0: self.dmm_warning_adv.show() self.dmm_warning_dev.show() else: @@ -747,7 +747,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): while not t_monitor.is_finished(): self.qapp.processEvents() - time.sleep (0.1) + time.sleep(0.1) self.AppListManager = AppmenuSelectManager(self.vm, self.app_list) @@ -942,7 +942,7 @@ def handle_exception(exc_type, exc_value, exc_traceback): "This is most likely a bug in Qubes Manager.

" "%s" % error + "
at line %d
of file %s.

" - % ( line, filename )) + % (line, filename)) msg_box.exec_()