Fixed some indents and whitespaces

Fixed indents and whitespace that pylint was complaining about.
This commit is contained in:
Marta Marczykowska-Górecka 2018-01-08 20:56:22 +01:00
parent ec3d6eb84a
commit 60143e6a91
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B

View File

@ -42,7 +42,7 @@ from .appmenu_select import AppmenuSelectManager
from . import firewall from . import firewall
from PyQt4 import QtCore, QtGui # pylint: disable=import-error from PyQt4 import QtCore, QtGui # pylint: disable=import-error
from . import ui_settingsdlg #pylint: disable=no-name-in-module from . import ui_settingsdlg # pylint: disable=no-name-in-module
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
@ -140,7 +140,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
def reject(self): def reject(self):
self.done(0) self.done(0)
#needed not to close the dialog before applying changes # needed not to close the dialog before applying changes
def accept(self): def accept(self):
pass pass
@ -278,8 +278,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
self.delete_vm_button.setEnabled(not self.vm.is_running()) self.delete_vm_button.setEnabled(not self.vm.is_running())
if self.vm.is_running(): if self.vm.is_running():
self.delete_vm_button.setText(self.tr('Delete VM ' self.delete_vm_button.setText(
'(cannot delete a running VM)')) self.tr('Delete VM (cannot delete a running VM)'))
if self.vm.qid == 0: if self.vm.qid == 0:
self.vmlabel.setVisible(False) self.vmlabel.setVisible(False)
@ -325,13 +325,13 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except AttributeError: except AttributeError:
self.autostart_vm.setVisible(False) self.autostart_vm.setVisible(False)
#type # type
self.type_label.setText(self.vm.klass) self.type_label.setText(self.vm.klass)
#installed by rpm # installed by rpm
self.rpm_label.setText('Yes' if self.vm.installed_by_rpm else 'No') self.rpm_label.setText('Yes' if self.vm.installed_by_rpm else 'No')
#networking info # networking info
if self.vm.netvm: if self.vm.netvm:
self.networking_groupbox.setEnabled(True) self.networking_groupbox.setEnabled(True)
self.ip_label.setText(self.vm.ip or "none") self.ip_label.setText(self.vm.ip or "none")
@ -340,7 +340,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
else: else:
self.networking_groupbox.setEnabled(False) self.networking_groupbox.setEnabled(False)
#max priv storage # max priv storage
self.priv_img_size = self.vm.volumes['private'].size // 1024**2 self.priv_img_size = self.vm.volumes['private'].size // 1024**2
self.max_priv_storage.setMinimum(self.priv_img_size) self.max_priv_storage.setMinimum(self.priv_img_size)
self.max_priv_storage.setValue(self.priv_img_size) self.max_priv_storage.setValue(self.priv_img_size)
@ -354,7 +354,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
def __apply_basic_tab__(self): def __apply_basic_tab__(self):
msg = [] msg = []
#vm label changed # vm label changed
try: try:
if self.vmlabel.isVisible(): if self.vmlabel.isVisible():
if self.vmlabel.currentIndex() != self.label_idx: if self.vmlabel.currentIndex() != self.label_idx:
@ -363,7 +363,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#vm template changed # vm template changed
try: try:
if self.template_name.currentIndex() != self.template_idx: if self.template_name.currentIndex() != self.template_idx:
self.vm.template = \ self.vm.template = \
@ -371,14 +371,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#vm netvm changed # vm netvm changed
try: try:
if self.netVM.currentIndex() != self.netvm_idx: if self.netVM.currentIndex() != self.netvm_idx:
self.vm.netvm = self.netvm_list[self.netVM.currentIndex()] self.vm.netvm = self.netvm_list[self.netVM.currentIndex()]
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#include in backups # include in backups
try: try:
if self.vm.include_in_backups != \ if self.vm.include_in_backups != \
self.include_in_backups.isChecked(): self.include_in_backups.isChecked():
@ -386,7 +386,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#run_in_debug_mode # run_in_debug_mode
try: try:
if self.run_in_debug_mode.isVisible(): if self.run_in_debug_mode.isVisible():
if self.vm.debug != self.run_in_debug_mode.isChecked(): if self.vm.debug != self.run_in_debug_mode.isChecked():
@ -394,7 +394,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#autostart_vm # autostart_vm
try: try:
if self.autostart_vm.isVisible(): if self.autostart_vm.isVisible():
if self.vm.autostart != self.autostart_vm.isChecked(): if self.vm.autostart != self.autostart_vm.isChecked():
@ -402,7 +402,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#max priv storage # max priv storage
priv_size = self.max_priv_storage.value() priv_size = self.max_priv_storage.value()
if self.priv_img_size != priv_size: if self.priv_img_size != priv_size:
try: try:
@ -410,7 +410,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#max sys storage # max sys storage
sys_size = self.root_resize.value() sys_size = self.root_resize.value()
if self.root_img_size != sys_size: if self.root_img_size != sys_size:
try: try:
@ -420,7 +420,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
return msg return msg
def check_mem_changes(self): def check_mem_changes(self):
if self.max_mem_size.value() < self.init_mem.value(): if self.max_mem_size.value() < self.init_mem.value():
QtGui.QMessageBox.warning( QtGui.QMessageBox.warning(
@ -453,10 +452,9 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
if not t_monitor.success: if not t_monitor.success:
QtGui.QMessageBox.warning(None, QtGui.QMessageBox.warning(None,
self.tr("Error!"), self.tr("Error!"),
self.tr("ERROR: {}").format( self.tr("ERROR: {}").format(
t_monitor.error_msg)) t_monitor.error_msg))
def _rename_vm(self, t_monitor, name): def _rename_vm(self, t_monitor, name):
try: try:
@ -470,7 +468,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
t_monitor.set_finished() t_monitor.set_finished()
def rename_vm(self): def rename_vm(self):
new_vm_name, ok = QtGui.QInputDialog.getText( new_vm_name, ok = QtGui.QInputDialog.getText(
@ -499,10 +496,9 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
self, self,
self.tr('Delete VM'), self.tr('Delete VM'),
self.tr('Are you absolutely sure you want to delete this VM? ' self.tr('Are you absolutely sure you want to delete this VM? '
'<br/> All VM settings and data will be irrevocably' '<br/> All VM settings and data will be irrevocably'
' deleted. <br/> If you are sure, please enter this ' ' deleted. <br/> If you are sure, please enter this '
'VM\'s name below.')) 'VM\'s name below.'))
if ok and answer == self.vm.name: if ok and answer == self.vm.name:
self._run_in_thread(self._remove_vm) self._run_in_thread(self._remove_vm)
@ -543,7 +539,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
def __init_advanced_tab__(self): def __init_advanced_tab__(self):
#mem/cpu # mem/cpu
# qubes_memory = QubesHost().memory_total/1024 # qubes_memory = QubesHost().memory_total/1024
self.init_mem.setValue(int(self.vm.memory)) self.init_mem.setValue(int(self.vm.memory))
@ -561,7 +557,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
bool(self.vm.features.get('service.meminfo-writer', True))) bool(self.vm.features.get('service.meminfo-writer', True)))
self.max_mem_size.setEnabled(self.include_in_balancing.isChecked()) self.max_mem_size.setEnabled(self.include_in_balancing.isChecked())
#in case VM is HVM # in case VM is HVM
if hasattr(self.vm, "kernel"): if hasattr(self.vm, "kernel"):
self.kernel_groupbox.setVisible(True) self.kernel_groupbox.setVisible(True)
self.kernel_list, self.kernel_idx = utils.prepare_kernel_choice( self.kernel_list, self.kernel_idx = utils.prepare_kernel_choice(
@ -588,7 +584,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
def __apply_advanced_tab__(self): def __apply_advanced_tab__(self):
msg = [] msg = []
#mem/cpu # mem/cpu
try: try:
if self.init_mem.value() != int(self.vm.memory): if self.init_mem.value() != int(self.vm.memory):
self.vm.memory = self.init_mem.value() self.vm.memory = self.init_mem.value()
@ -601,9 +597,9 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#include_in_memory_balancing applied in services tab # include_in_memory_balancing applied in services tab
#in case VM is not Linux # in case VM is not Linux
if hasattr(self.vm, "kernel") and self.kernel_groupbox.isVisible(): if hasattr(self.vm, "kernel") and self.kernel_groupbox.isVisible():
try: try:
if self.kernel.currentIndex() != self.kernel_idx: if self.kernel.currentIndex() != self.kernel_idx:
@ -612,7 +608,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
#vm default_dispvm changed # vm default_dispvm changed
try: try:
if self.default_dispvm.currentIndex() != self.default_dispvm_idx: if self.default_dispvm.currentIndex() != self.default_dispvm_idx:
self.vm.default_dispvm = \ self.vm.default_dispvm = \
@ -644,7 +640,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
self.ident = ident self.ident = ident
persistent = [ass.ident.replace('_', ':') persistent = [ass.ident.replace('_', ':')
for ass in self.vm.devices['pci'].persistent()] for ass in self.vm.devices['pci'].persistent()]
for name, ident in devs: for name, ident in devs:
if ident in persistent: if ident in persistent:
@ -669,16 +665,15 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
self.dev_list.setEnabled(True) self.dev_list.setEnabled(True)
self.turn_off_vm_to_modify_devs.setVisible(False) self.turn_off_vm_to_modify_devs.setVisible(False)
def __apply_devices_tab__(self): def __apply_devices_tab__(self):
msg = [] msg = []
try: try:
old = [ass.ident.replace('_', ':') old = [ass.ident.replace('_', ':')
for ass in self.vm.devices['pci'].persistent()] for ass in self.vm.devices['pci'].persistent()]
new = [self.dev_list.selected_list.item(i).ident new = [self.dev_list.selected_list.item(i).ident
for i in range(self.dev_list.selected_list.count())] for i in range(self.dev_list.selected_list.count())]
for ident in new: for ident in new:
if ident not in old: if ident not in old:
ass = devices.DeviceAssignment( ass = devices.DeviceAssignment(
@ -774,7 +769,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
service = feature[len('service.'):] service = feature[len('service.'):]
item = QtGui.QListWidgetItem(service) item = QtGui.QListWidgetItem(service)
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked
if self.vm.features[feature] if self.vm.features[feature]
else ui_settingsdlg.QtCore.Qt.Unchecked) else ui_settingsdlg.QtCore.Qt.Unchecked)
self.services_list.addItem(item) self.services_list.addItem(item)
self.new_srv_dict[service] = self.vm.features[feature] self.new_srv_dict[service] = self.vm.features[feature]
@ -815,7 +810,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
item = self.services_list.takeItem(row) item = self.services_list.takeItem(row)
del self.new_srv_dict[str(item.text())] del self.new_srv_dict[str(item.text())]
def services_item_clicked(self, item): def services_item_clicked(self, item):
if str(item.text()) == 'meminfo-writer': if str(item.text()) == 'meminfo-writer':
if item.checkState() == ui_settingsdlg.QtCore.Qt.Checked: if item.checkState() == ui_settingsdlg.QtCore.Qt.Checked:
@ -825,7 +819,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
if self.include_in_balancing.isChecked(): if self.include_in_balancing.isChecked():
self.include_in_balancing.setChecked(False) self.include_in_balancing.setChecked(False)
def __apply_services_tab__(self): def __apply_services_tab__(self):
msg = [] msg = []
@ -861,9 +854,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
return msg return msg
######### firewall tab related ######### firewall tab related
def set_fw_model(self, model): def set_fw_model(self, model):
self.fw_model = model self.fw_model = model
self.rulesTreeView.setModel(model) self.rulesTreeView.setModel(model)
@ -942,10 +933,10 @@ def handle_exception(exc_type, exc_value, exc_traceback):
while stacktrace: while stacktrace:
(filename, line, func, txt) = stacktrace.pop() (filename, line, func, txt) = stacktrace.pop()
strace += "----\n" strace += "----\n"
strace += "line: %s\n" %txt strace += "line: %s\n" % txt
strace += "func: %s\n" %func strace += "func: %s\n" % func
strace += "line no.: %d\n" %line strace += "line no.: %d\n" % line
strace += "file: %s\n" %filename strace += "file: %s\n" % filename
msg_box = QtGui.QMessageBox() msg_box = QtGui.QMessageBox()
msg_box.setDetailedText(strace) msg_box.setDetailedText(strace)
@ -963,13 +954,14 @@ def handle_exception(exc_type, exc_value, exc_traceback):
parser = QubesArgumentParser(vmname_nargs=1) parser = QubesArgumentParser(vmname_nargs=1)
parser.add_argument('--tab', metavar='TAB', parser.add_argument('--tab', metavar='TAB',
action='store', action='store',
choices=VMSettingsWindow.tabs_indices.keys()) choices=VMSettingsWindow.tabs_indices.keys())
parser.set_defaults( parser.set_defaults(
tab='basic', tab='basic',
) )
def main(args=None): def main(args=None):
args = parser.parse_args(args) args = parser.parse_args(args)
vm = args.domains.pop() vm = args.domains.pop()