Final corrections
Errors that my local pylint ignored and travis' pylint didn't.
This commit is contained in:
		
							parent
							
								
									c708830af2
								
							
						
					
					
						commit
						135060dfe7
					
				@ -32,6 +32,7 @@ disable=
 | 
			
		||||
  logging-format-interpolation,
 | 
			
		||||
  missing-docstring,
 | 
			
		||||
  star-args,
 | 
			
		||||
  useless-super-delegation,
 | 
			
		||||
  wrong-import-order
 | 
			
		||||
 | 
			
		||||
[REPORTS]
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@
 | 
			
		||||
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
import PyQt4.QtGui
 | 
			
		||||
import PyQt4.QtGui  # pylint: disable=import-error
 | 
			
		||||
 | 
			
		||||
# TODO description in tooltip
 | 
			
		||||
# TODO icon
 | 
			
		||||
 | 
			
		||||
@ -21,8 +21,8 @@ import sys
 | 
			
		||||
import subprocess
 | 
			
		||||
from . import utils
 | 
			
		||||
from . import firewall
 | 
			
		||||
from . import ui_bootfromdevice
 | 
			
		||||
from PyQt4 import QtGui, QtCore
 | 
			
		||||
from . import ui_bootfromdevice  # pylint: disable=no-name-in-module
 | 
			
		||||
from PyQt4 import QtGui, QtCore  # pylint: disable=import-error
 | 
			
		||||
import qubesadmin.tools.qvm_start as qvm_start
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ import threading
 | 
			
		||||
import time
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
from PyQt4 import QtCore, QtGui
 | 
			
		||||
from PyQt4 import QtCore, QtGui  # pylint: disable=import-error
 | 
			
		||||
 | 
			
		||||
import qubesadmin
 | 
			
		||||
import qubesadmin.tools
 | 
			
		||||
@ -34,7 +34,7 @@ import qubesadmin.exc
 | 
			
		||||
 | 
			
		||||
from . import utils
 | 
			
		||||
 | 
			
		||||
from .ui_newappvmdlg import Ui_NewVMDlg
 | 
			
		||||
from .ui_newappvmdlg import Ui_NewVMDlg  # pylint: disable=import-error
 | 
			
		||||
from .thread_monitor import ThreadMonitor
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -75,7 +75,7 @@ class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg):
 | 
			
		||||
        self.name.selectAll()
 | 
			
		||||
        self.name.setFocus()
 | 
			
		||||
 | 
			
		||||
        if len(self.template_list) == 0:
 | 
			
		||||
        if not self.template_list:
 | 
			
		||||
            QtGui.QMessageBox.warning(None,
 | 
			
		||||
                self.tr('No template available!'),
 | 
			
		||||
                self.tr('Cannot create a qube when no template exists.'))
 | 
			
		||||
 | 
			
		||||
@ -21,16 +21,17 @@
 | 
			
		||||
import datetime
 | 
			
		||||
import re
 | 
			
		||||
 | 
			
		||||
from PyQt4 import QtCore, QtGui
 | 
			
		||||
from PyQt4 import QtCore, QtGui  # pylint: disable=import-error
 | 
			
		||||
import qubesadmin.firewall
 | 
			
		||||
 | 
			
		||||
from . import ui_newfwruledlg
 | 
			
		||||
from . import ui_newfwruledlg  # pylint: disable=no-name-in-module
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FirewallModifiedOutsideError(ValueError):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class QIPAddressValidator(QtGui.QValidator):
 | 
			
		||||
    # pylint: disable=too-few-public-methods
 | 
			
		||||
    def __init__(self, parent=None):
 | 
			
		||||
        super(QIPAddressValidator, self).__init__(parent)
 | 
			
		||||
 | 
			
		||||
@ -38,7 +39,7 @@ class QIPAddressValidator(QtGui.QValidator):
 | 
			
		||||
        # pylint: disable=too-many-return-statements,no-self-use
 | 
			
		||||
        hostname = str(input_string)
 | 
			
		||||
 | 
			
		||||
        if len(hostname) > 255 or len(hostname) == 0:
 | 
			
		||||
        if len(hostname) > 255 or not hostname:
 | 
			
		||||
            return (QtGui.QValidator.Intermediate, input_string, pos)
 | 
			
		||||
 | 
			
		||||
        if hostname == "*":
 | 
			
		||||
@ -89,7 +90,7 @@ class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
 | 
			
		||||
 | 
			
		||||
    def accept(self):
 | 
			
		||||
        if self.tcp_radio.isChecked() or self.udp_radio.isChecked():
 | 
			
		||||
            if len(self.serviceComboBox.currentText()) == 0:
 | 
			
		||||
            if not self.serviceComboBox.currentText():
 | 
			
		||||
                msg = QtGui.QMessageBox()
 | 
			
		||||
                msg.warning(self, self.tr("Firewall rule"),
 | 
			
		||||
                    self.tr("You need to fill service "
 | 
			
		||||
@ -163,8 +164,6 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
 | 
			
		||||
        self.__children = None # list of rules in the FW
 | 
			
		||||
 | 
			
		||||
    def sort(self, idx, order):
 | 
			
		||||
        from operator import attrgetter
 | 
			
		||||
 | 
			
		||||
        rev = (order == QtCore.Qt.AscendingOrder)
 | 
			
		||||
        self.children.sort(key=lambda x: self.get_column_string(idx, x)
 | 
			
		||||
                           , reverse=rev)
 | 
			
		||||
@ -192,31 +191,25 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
 | 
			
		||||
        if col == 0:
 | 
			
		||||
            if rule.dsthost is None:
 | 
			
		||||
                return "*"
 | 
			
		||||
            else:
 | 
			
		||||
                if rule.dsthost.type == 'dst4'\
 | 
			
		||||
                        and rule.dsthost.prefixlen == '32':
 | 
			
		||||
                    return str(rule.dsthost)[:-3]
 | 
			
		||||
                elif rule.dsthost.type == 'dst6'\
 | 
			
		||||
                        and rule.dsthost.prefixlen == '128':
 | 
			
		||||
                    return str(rule.dsthost)[:-4]
 | 
			
		||||
                else:
 | 
			
		||||
                    return str(rule.dsthost)
 | 
			
		||||
            if rule.dsthost.type == 'dst4' and rule.dsthost.prefixlen == '32':
 | 
			
		||||
                return str(rule.dsthost)[:-3]
 | 
			
		||||
            if rule.dsthost.type == 'dst6' and rule.dsthost.prefixlen == '128':
 | 
			
		||||
                return str(rule.dsthost)[:-4]
 | 
			
		||||
            return str(rule.dsthost)
 | 
			
		||||
 | 
			
		||||
        # Service
 | 
			
		||||
        if col == 1:
 | 
			
		||||
            if rule.dstports is None:
 | 
			
		||||
                return "any"
 | 
			
		||||
            elif rule.dstports.range[0] != rule.dstports.range[1]:
 | 
			
		||||
            if rule.dstports.range[0] != rule.dstports.range[1]:
 | 
			
		||||
                return str(rule.dstports)
 | 
			
		||||
            else:
 | 
			
		||||
                return self.get_service_name(rule.dstports)
 | 
			
		||||
            return self.get_service_name(rule.dstports)
 | 
			
		||||
 | 
			
		||||
        # Protocol
 | 
			
		||||
        if col == 2:
 | 
			
		||||
            if rule.proto is None:
 | 
			
		||||
                return "any"
 | 
			
		||||
            else:
 | 
			
		||||
                return str(rule.proto)
 | 
			
		||||
            return str(rule.proto)
 | 
			
		||||
        return "unknown"
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
@ -434,8 +427,7 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
 | 
			
		||||
        parent_item = index.internalPointer()
 | 
			
		||||
        if parent_item is not None:
 | 
			
		||||
            return False
 | 
			
		||||
        else:
 | 
			
		||||
            return True
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
    def data(self, index, role=QtCore.Qt.DisplayRole):
 | 
			
		||||
        if index.isValid() and role == QtCore.Qt.DisplayRole:
 | 
			
		||||
@ -484,4 +476,3 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
 | 
			
		||||
 | 
			
		||||
    def __len__(self):
 | 
			
		||||
        return len(self.children)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -24,12 +24,12 @@ import sys
 | 
			
		||||
import os
 | 
			
		||||
import os.path
 | 
			
		||||
import traceback
 | 
			
		||||
from PyQt4 import QtCore, QtGui
 | 
			
		||||
from PyQt4 import QtCore, QtGui  # pylint: disable=import-error
 | 
			
		||||
 | 
			
		||||
from qubesadmin import Qubes
 | 
			
		||||
from qubesadmin.utils import parse_size, updates_vms_status
 | 
			
		||||
 | 
			
		||||
from . import ui_globalsettingsdlg
 | 
			
		||||
from . import ui_globalsettingsdlg  # pylint: disable=no-name-in-module
 | 
			
		||||
 | 
			
		||||
from configparser import ConfigParser
 | 
			
		||||
 | 
			
		||||
@ -181,7 +181,6 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def __init_mem_defaults__(self):
 | 
			
		||||
    # pylint: disable=redefined-variable-type
 | 
			
		||||
        #qmemman settings
 | 
			
		||||
        self.qmemman_config = ConfigParser()
 | 
			
		||||
        self.vm_min_mem_val = '200MiB'  #str(qmemman_algo.MIN_PREFMEM)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
from PyQt4 import QtCore, QtGui
 | 
			
		||||
from . import ui_multiselectwidget
 | 
			
		||||
from PyQt4 import QtCore, QtGui  # pylint: disable=import-error
 | 
			
		||||
from . import ui_multiselectwidget # pylint: disable=no-name-in-module
 | 
			
		||||
 | 
			
		||||
class MultiSelectWidget(
 | 
			
		||||
    ui_multiselectwidget.Ui_MultiSelectWidget, QtGui.QWidget):
 | 
			
		||||
@ -65,4 +65,3 @@ class MultiSelectWidget(
 | 
			
		||||
    def clear(self):
 | 
			
		||||
        self.available_list.clear()
 | 
			
		||||
        self.selected_list.clear()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -39,9 +39,9 @@ from . import thread_monitor
 | 
			
		||||
 | 
			
		||||
from .appmenu_select import AppmenuSelectManager
 | 
			
		||||
from . import firewall
 | 
			
		||||
from PyQt4 import QtCore, QtGui
 | 
			
		||||
from PyQt4 import QtCore, QtGui  # pylint: disable=import-error
 | 
			
		||||
 | 
			
		||||
from . import ui_settingsdlg
 | 
			
		||||
from . import ui_settingsdlg  #pylint: disable=no-name-in-module
 | 
			
		||||
 | 
			
		||||
# pylint: disable=too-many-instance-attributes
 | 
			
		||||
class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
 | 
			
		||||
@ -177,16 +177,16 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
 | 
			
		||||
        ret = []
 | 
			
		||||
        try:
 | 
			
		||||
            ret_tmp = self.__apply_basic_tab__()
 | 
			
		||||
            if len(ret_tmp) > 0:
 | 
			
		||||
            if ret_tmp:
 | 
			
		||||
                ret += ["Basic tab:"] + ret_tmp
 | 
			
		||||
            ret_tmp = self.__apply_advanced_tab__()
 | 
			
		||||
            if len(ret_tmp) > 0:
 | 
			
		||||
            if ret_tmp:
 | 
			
		||||
                ret += ["Advanced tab:"] + ret_tmp
 | 
			
		||||
            ret_tmp = self.__apply_devices_tab__()
 | 
			
		||||
            if len(ret_tmp) > 0:
 | 
			
		||||
            if ret_tmp:
 | 
			
		||||
                ret += ["Devices tab:"] + ret_tmp
 | 
			
		||||
            ret_tmp = self.__apply_services_tab__()
 | 
			
		||||
            if len(ret_tmp) > 0:
 | 
			
		||||
            if ret_tmp:
 | 
			
		||||
                ret += ["Sevices tab:"] + ret_tmp
 | 
			
		||||
        except qubesadmin.exc.QubesException as qex:
 | 
			
		||||
            ret.append(self.tr('Error while saving changes: ') + str(qex))
 | 
			
		||||
@ -212,7 +212,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
 | 
			
		||||
        except Exception as ex:  # pylint: disable=broad-except
 | 
			
		||||
            ret += [self.tr("Applications tab:"), repr(ex)]
 | 
			
		||||
 | 
			
		||||
        if len(ret) > 0:
 | 
			
		||||
        if ret:
 | 
			
		||||
            t_monitor.set_error_msg('\n'.join(ret))
 | 
			
		||||
 | 
			
		||||
        utils.debug('\n'.join(ret))
 | 
			
		||||
@ -899,7 +899,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
 | 
			
		||||
 | 
			
		||||
        selected = self.rulesTreeView.selectedIndexes()
 | 
			
		||||
 | 
			
		||||
        if len(selected) > 0:
 | 
			
		||||
        if selected:
 | 
			
		||||
            dialog = firewall.NewFwRuleDlg()
 | 
			
		||||
            dialog.set_ok_state(True)
 | 
			
		||||
            row = self.rulesTreeView.selectedIndexes().pop().row()
 | 
			
		||||
@ -923,7 +923,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
 | 
			
		||||
 | 
			
		||||
    strace = ""
 | 
			
		||||
    stacktrace = traceback.extract_tb(exc_traceback)
 | 
			
		||||
    while len(stacktrace) > 0:
 | 
			
		||||
    while stacktrace:
 | 
			
		||||
        (filename, line, func, txt) = stacktrace.pop()
 | 
			
		||||
        strace += "----\n"
 | 
			
		||||
        strace += "line: %s\n" %txt
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import PyQt4.QtCore
 | 
			
		||||
import PyQt4.QtCore  # pylint: disable=import-error
 | 
			
		||||
 | 
			
		||||
import threading
 | 
			
		||||
 | 
			
		||||
@ -40,4 +40,3 @@ class ThreadMonitor(PyQt4.QtCore.QObject):
 | 
			
		||||
 | 
			
		||||
    def set_finished(self):
 | 
			
		||||
        self.event_finished.set()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ import os
 | 
			
		||||
import re
 | 
			
		||||
import qubesadmin
 | 
			
		||||
 | 
			
		||||
from PyQt4.QtGui import QIcon
 | 
			
		||||
from PyQt4.QtGui import QIcon  # pylint: disable=import-error
 | 
			
		||||
 | 
			
		||||
def _filter_internal(vm):
 | 
			
		||||
    return (not vm.klass == 'AdminVM'
 | 
			
		||||
@ -65,7 +65,7 @@ def prepare_choice(widget, holder, propname, choice, default,
 | 
			
		||||
        choice_list = filter(_filter_internal, choice_list)
 | 
			
		||||
    if filter_function is not None:
 | 
			
		||||
        choice_list = filter(filter_function, choice_list)
 | 
			
		||||
    choice_list = list(choice_list) # pylint: disable=redefined-variable-type
 | 
			
		||||
    choice_list = list(choice_list)
 | 
			
		||||
 | 
			
		||||
    if allow_default:
 | 
			
		||||
        choice_list.insert(0, qubesadmin.DEFAULT)
 | 
			
		||||
@ -154,7 +154,7 @@ def get_path_from_vm(vm, service_name):
 | 
			
		||||
 | 
			
		||||
    untrusted_path = stdout.decode(encoding='ascii')[:path_max_len]
 | 
			
		||||
 | 
			
		||||
    if len(untrusted_path) == 0:
 | 
			
		||||
    if not untrusted_path:
 | 
			
		||||
        return None
 | 
			
		||||
    if path_re.match(untrusted_path):
 | 
			
		||||
        assert '../' not in untrusted_path
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user