Misc errors part 2
Renamed variable from 'input' to 'input_string' and moved imports to a better place (that is, at the beginning of the module and not inside of a function).
This commit is contained in:
parent
8b296fab0d
commit
8cfc93c70c
@ -34,15 +34,15 @@ class QIPAddressValidator(QtGui.QValidator):
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(QIPAddressValidator, self).__init__(parent)
|
super(QIPAddressValidator, self).__init__(parent)
|
||||||
|
|
||||||
def validate(self, input, pos):
|
def validate(self, input_string, pos):
|
||||||
# pylint: disable=too-many-return-statements,no-self-use
|
# pylint: disable=too-many-return-statements,no-self-use
|
||||||
hostname = str(input)
|
hostname = str(input_string)
|
||||||
|
|
||||||
if len(hostname) > 255 or len(hostname) == 0:
|
if len(hostname) > 255 or len(hostname) == 0:
|
||||||
return (QtGui.QValidator.Intermediate, input, pos)
|
return (QtGui.QValidator.Intermediate, input_string, pos)
|
||||||
|
|
||||||
if hostname == "*":
|
if hostname == "*":
|
||||||
return (QtGui.QValidator.Acceptable, input, pos)
|
return (QtGui.QValidator.Acceptable, input_string, pos)
|
||||||
|
|
||||||
unmask = hostname.split("/", 1)
|
unmask = hostname.split("/", 1)
|
||||||
if len(unmask) == 2:
|
if len(unmask) == 2:
|
||||||
@ -50,25 +50,25 @@ class QIPAddressValidator(QtGui.QValidator):
|
|||||||
mask = unmask[1]
|
mask = unmask[1]
|
||||||
if mask.isdigit() or mask == "":
|
if mask.isdigit() or mask == "":
|
||||||
if re.match(r"^([0-9]{1,3}\.){3}[0-9]{1,3}$", hostname) is None:
|
if re.match(r"^([0-9]{1,3}\.){3}[0-9]{1,3}$", hostname) is None:
|
||||||
return (QtGui.QValidator.Invalid, input, pos)
|
return (QtGui.QValidator.Invalid, input_string, pos)
|
||||||
if mask != "":
|
if mask != "":
|
||||||
mask = int(unmask[1])
|
mask = int(unmask[1])
|
||||||
if mask < 0 or mask > 32:
|
if mask < 0 or mask > 32:
|
||||||
return (QtGui.QValidator.Invalid, input, pos)
|
return (QtGui.QValidator.Invalid, input_string, pos)
|
||||||
else:
|
else:
|
||||||
return (QtGui.QValidator.Invalid, input, pos)
|
return (QtGui.QValidator.Invalid, input_string, pos)
|
||||||
|
|
||||||
if hostname[-1:] == ".":
|
if hostname[-1:] == ".":
|
||||||
hostname = hostname[:-1]
|
hostname = hostname[:-1]
|
||||||
|
|
||||||
if hostname[-1:] == "-":
|
if hostname[-1:] == "-":
|
||||||
return (QtGui.QValidator.Intermediate, input, pos)
|
return (QtGui.QValidator.Intermediate, input_string, pos)
|
||||||
|
|
||||||
allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
|
allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
|
||||||
if all(allowed.match(x) for x in hostname.split(".")):
|
if all(allowed.match(x) for x in hostname.split(".")):
|
||||||
return (QtGui.QValidator.Acceptable, input, pos)
|
return (QtGui.QValidator.Acceptable, input_string, pos)
|
||||||
|
|
||||||
return (QtGui.QValidator.Invalid, input, pos)
|
return (QtGui.QValidator.Invalid, input_string, pos)
|
||||||
|
|
||||||
class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
|
class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import os.path
|
||||||
|
import traceback
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from qubesadmin import Qubes
|
from qubesadmin import Qubes
|
||||||
@ -297,9 +299,6 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
|
|||||||
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
|
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
|
||||||
|
|
||||||
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, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
|
||||||
filename = os.path.basename(filename)
|
filename = os.path.basename(filename)
|
||||||
error = "%s: %s" % (exc_type.__name__, exc_value)
|
error = "%s: %s" % (exc_type.__name__, exc_value)
|
||||||
|
Loading…
Reference in New Issue
Block a user