1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Fix pep8 errors in all of zenmap

This commit is contained in:
dmiller
2015-12-11 23:11:47 +00:00
parent 24f5f35d3e
commit 3567d72b17
28 changed files with 282 additions and 275 deletions

View File

@@ -265,7 +265,7 @@ if __name__ == "__main__":
# Testing application
polar = PolarCoordinate(1, math.pi)
cartesian = CartesianCoordinate(-1, 0)
cartesian = CartesianCoordinate(-1, 0)
print polar.to_cartesian()
print cartesian.to_polar()

View File

@@ -121,8 +121,8 @@
import os
INFO = {'name': 'RadialNet',
'version': '0.44',
'website': 'http://www.dca.ufrn.br/~joaomedeiros/radialnet/',
'authors': ['João Paulo de Souza Medeiros'],
INFO = {'name': 'RadialNet',
'version': '0.44',
'website': 'http://www.dca.ufrn.br/~joaomedeiros/radialnet/',
'authors': ['João Paulo de Souza Medeiros'],
'copyright': 'Copyright (C) 2007, 2008 Insecure.Com LLC'}

View File

@@ -133,12 +133,12 @@ PORTS_HEADER = [
_('Port'), _('Protocol'), _('State'), _('Service'), _('Method')]
EXTRAPORTS_HEADER = [_('Count'), _('State'), _('Reasons')]
SERVICE_COLORS = {'open': '#ffd5d5',
'closed': '#d5ffd5',
'filtered': '#ffffd5',
'unfiltered': '#ffd5d5',
'open|filtered': '#ffd5d5',
'closed|filtered': '#d5ffd5'}
SERVICE_COLORS = {'open': '#ffd5d5', # noqa
'closed': '#d5ffd5', # noqa
'filtered': '#ffffd5', # noqa
'unfiltered': '#ffd5d5', # noqa
'open|filtered': '#ffd5d5', # noqa
'closed|filtered': '#d5ffd5'} # noqa
UNKNOWN_SERVICE_COLOR = '#d5d5d5'
TRACE_HEADER = [_('TTL'), _('RTT'), _('IP'), _('Hostname')]
@@ -148,8 +148,8 @@ TRACE_TEXT = _(
NO_TRACE_TEXT = _("No traceroute information available.")
HOP_COLOR = {'known': '#ffffff',
'unknown': '#cccccc'}
HOP_COLOR = {'known': '#ffffff', # noqa
'unknown': '#cccccc'} # noqa
SYSTEM_ADDRESS_TEXT = "[%s] %s"

View File

@@ -144,10 +144,10 @@ REGION_GREEN = 2
SQUARE_TYPES = ['router', 'switch', 'wap']
ICON_DICT = {'router': 'router',
'switch': 'switch',
'wap': 'wireless',
'firewall': 'firewall'}
ICON_DICT = {'router': 'router',
'switch': 'switch',
'wap': 'wireless',
'firewall': 'firewall'}
POINTER_JUMP_TO = 0
POINTER_INFO = 1

View File

@@ -177,13 +177,14 @@ class TracerouteHostInfo(object):
def find_hop_by_ttl(hops, ttl):
assert ttl >= 0, "ttl must be non-negative"
if ttl == 0: # Same machine (i.e. localhost)
if ttl == 0: # Same machine (i.e. localhost)
return {"ipaddr": "127.0.0.1/8"}
for h in hops:
if ttl == int(h["ttl"]):
return h
return None
def make_graph_from_hosts(hosts):
#hosts = parser.get_root().search_children('host', deep=True)
graph = Graph()
@@ -249,14 +250,14 @@ def make_graph_from_hosts(hosts):
else:
graph.set_connection(node, prev_node)
else:
# Add an "anonymous" node only if there isn't already a node
# equivalent to it (i.e. at same distance from the previous
# "real" node)
# Add an "anonymous" node only if there isn't already a
# node equivalent to it (i.e. at same distance from the
# previous "real" node)
pre_hop = None
pre_hop_distance = 0
for i in range(1, ttl + 1):
pre_hop = find_hop_by_ttl(hops, ttl-i)
pre_hop = find_hop_by_ttl(hops, ttl - i)
if pre_hop is not None:
pre_hop_distance = i
break
@@ -264,29 +265,33 @@ def make_graph_from_hosts(hosts):
post_hop = None
post_hop_distance = 0
for i in range(1, max(ttls) - ttl):
post_hop = find_hop_by_ttl(hops, ttl+i)
post_hop = find_hop_by_ttl(hops, ttl + i)
if post_hop is not None:
post_hop_distance = i
break
assert pre_hop is not None, "pre_hop should have become localhost if nothing else"
assert pre_hop is not None, \
"pre_hop should have become localhost if nothing else" # noqa
ancestor_key = (pre_hop["ipaddr"], pre_hop_distance)
descendant_key = None
if post_hop is not None:
descendant_key = (post_hop["ipaddr"], post_hop_distance)
descendant_key = \
(post_hop["ipaddr"], post_hop_distance)
if ancestor_key in ancestor_node_cache:
node = ancestor_node_cache[ancestor_key]
elif descendant_key is not None and descendant_key in descendant_node_cache:
elif (descendant_key is not None and
descendant_key in descendant_node_cache):
node = descendant_node_cache[descendant_key]
graph.set_connection(node, prev_node)
else:
node = NetNode()
nodes.append(node)
node.set_draw_info({"valid":False})
node.set_draw_info({"color":(1,1,1), "radius":NONE_RADIUS})
node.set_draw_info({"valid": False})
node.set_draw_info(
{"color": (1, 1, 1), "radius": NONE_RADIUS})
graph.set_connection(node, prev_node)

View File

@@ -381,15 +381,15 @@ for dir in dirs:
continue
if os.path.isdir(output):
os.chmod(output, S_IRWXU | \
S_IRGRP | \
S_IXGRP | \
S_IROTH | \
os.chmod(output, S_IRWXU |
S_IRGRP |
S_IXGRP |
S_IROTH |
S_IXOTH)
else:
os.chmod(output, S_IRUSR | \
S_IWUSR | \
S_IRGRP | \
os.chmod(output, S_IRUSR |
S_IWUSR |
S_IRGRP |
S_IROTH)
def fix_paths(self):

View File

@@ -15,15 +15,18 @@ import xml.sax
directory = None
def escape(s):
return '"' + s.encode("UTF-8").replace('"', '\\"') + '"'
def output_msgid(msgid, locator):
print
print u"#: %s:%d" % (locator.getSystemId(), locator.getLineNumber())
print u"msgid", escape(msgid)
print u"msgstr", escape(u"")
class Handler (xml.sax.handler.ContentHandler):
def setDocumentLocator(self, locator):
self.locator = locator

View File

@@ -7,7 +7,7 @@ if __name__ == "__main__":
import glob
import os
if not hasattr(unittest.defaultTestLoader, "discover"):
print("Python unittest discovery missing. Requires Python 2.7 or newer.")
print("Python unittest discovery missing. Requires Python 2.7 or newer.") # noqa
sys.exit(0)
os.chdir("..")

View File

@@ -256,7 +256,8 @@ class NetworkInventory(object):
#remove ports which are no longer up
if old_date < new_date:
for defunct_port in old_list:
#Check if defunct_port is in ports and that the protocol matches
# Check if defunct_port is in ports
# and that the protocol matches
port_number = int(defunct_port['portid'])
if port_number in ports:
if defunct_port['protocol'] in ports[port_number]:
@@ -520,9 +521,9 @@ class FilteredNetworkInventory(NetworkInventory):
return len(self.network_inventory.hosts)
def match_keyword(self, host, keyword):
return self.match_os(host, keyword) or\
self.match_target(host, keyword) or\
self.match_service(host, keyword)
return (self.match_os(host, keyword) or
self.match_target(host, keyword) or
self.match_service(host, keyword))
def match_target(self, host, name):
return HostSearch.match_target(host, name)
@@ -663,8 +664,8 @@ class FilteredNetworkInventoryTest(unittest.TestCase):
class PortChangeTest(unittest.TestCase):
def test_port(self):
"""Verify that the port status (open/filtered/closed) is displayed """ \
"""correctly when the port status changes in newer scans"""
"""Verify that the port status (open/filtered/closed) is displayed
correctly when the port status changes in newer scans"""
from zenmapCore.NmapParser import NmapParser
inv = NetworkInventory()
scan1 = NmapParser()

View File

@@ -261,10 +261,11 @@ class NmapCommand(object):
os.kill(self.command_process.pid, SIGTERM)
for i in range(10):
sleep(0.5)
if self.command_process.poll() is not None: # Process has been TERMinated
if self.command_process.poll() is not None:
# Process has been TERMinated
break
else:
log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.")
log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.") # noqa
os.kill(self.command_process.pid, SIGKILL)
self.command_process.wait()
except:

View File

@@ -552,37 +552,37 @@ class NmapOptions(object):
opt, arg = result
if opt in ("6", "A", "F", "h", "n", "R", "r", "V"):
self["-" + opt] = True
elif opt in (\
"allports",
"append-output",
"badsum",
"defeat-rst-ratelimit",
"fuzzy",
"help",
"iflist",
"log-errors",
"no-stylesheet",
"open",
"osscan-guess",
"osscan-limit",
"packet-trace",
"privileged",
"randomize-hosts",
"reason",
"release-memory",
"script-trace",
"script-updatedb",
"send-eth",
"send-ip",
"system-dns",
"traceroute",
"unprivileged",
"version",
"version-all",
"version-light",
"version-trace",
"webxml",
):
elif opt in (
"allports",
"append-output",
"badsum",
"defeat-rst-ratelimit",
"fuzzy",
"help",
"iflist",
"log-errors",
"no-stylesheet",
"open",
"osscan-guess",
"osscan-limit",
"packet-trace",
"privileged",
"randomize-hosts",
"reason",
"release-memory",
"script-trace",
"script-updatedb",
"send-eth",
"send-ip",
"system-dns",
"traceroute",
"unprivileged",
"version",
"version-all",
"version-light",
"version-trace",
"webxml",
):
self["--" + opt] = True
elif opt in ("b", "D", "e", "g", "i", "iL", "m", "M", "o", "oA", "oG",
"oM", "oN", "oS", "oX", "p", "S", "sI"):
@@ -591,43 +591,43 @@ class NmapOptions(object):
self["-" + opt] = arg
else:
self.extras.extend(("-" + opt, arg))
elif opt in (\
"datadir",
"data-length",
"dns-servers",
"exclude",
"excludefile",
"host-timeout",
"initial-rtt-timeout",
"ip-options",
"max-hostgroup",
"max-os-tries",
"max-parallelism",
"max-rate",
"max-retries",
"max-rtt-timeout",
"max-scan-delay",
"min-hostgroup",
"min-parallelism",
"min-rate",
"min-retries",
"min-rtt-timeout",
"mtu",
"port-ratio",
"scan-delay",
"scanflags",
"script",
"script-args",
"script-help",
"servicedb",
"source-port",
"spoof-mac",
"stylesheet",
"top-ports",
"ttl",
"versiondb",
"version-intensity",
):
elif opt in (
"datadir",
"data-length",
"dns-servers",
"exclude",
"excludefile",
"host-timeout",
"initial-rtt-timeout",
"ip-options",
"max-hostgroup",
"max-os-tries",
"max-parallelism",
"max-rate",
"max-retries",
"max-rtt-timeout",
"max-scan-delay",
"min-hostgroup",
"min-parallelism",
"min-rate",
"min-retries",
"min-rtt-timeout",
"mtu",
"port-ratio",
"scan-delay",
"scanflags",
"script",
"script-args",
"script-help",
"servicedb",
"source-port",
"spoof-mac",
"stylesheet",
"top-ports",
"ttl",
"versiondb",
"version-intensity",
):
assert arg is not None
if self["--" + opt] is None:
self["--" + opt] = arg
@@ -795,11 +795,12 @@ class NmapOptions(object):
opt_list.extend((opt, self[opt]))
for opt in ("--min-hostgroup", "--max-hostgroup",
"--min-parallelism", "--max-parallelism",
"--min-rtt-timeout", "--max-rtt-timeout", "--initial-rtt-timeout",
"--scan-delay", "--max-scan-delay",
"--min-rate", "--max-rate",
"--max-retries", "--max-os-tries", "--host-timeout"):
"--min-parallelism", "--max-parallelism",
"--min-rtt-timeout", "--max-rtt-timeout",
"--initial-rtt-timeout",
"--scan-delay", "--max-scan-delay",
"--min-rate", "--max-rate",
"--max-retries", "--max-os-tries", "--host-timeout"):
if self[opt] is not None:
opt_list.extend((opt, self[opt]))
@@ -815,68 +816,68 @@ class NmapOptions(object):
elif self["-PB"]:
opt_list.append("-PB")
for opt in (\
"--allports",
"--append-output",
"--badsum",
"--defeat-rst-ratelimit",
"--fuzzy",
"--help",
"--iflist",
"--log-errors",
"--no-stylesheet",
"--open",
"--osscan-guess",
"--osscan-limit",
"--packet-trace",
"--privileged",
"-r",
"-R",
"--randomize-hosts",
"--reason",
"--release-memory",
"--script-trace",
"--script-updatedb",
"--send-eth",
"--send-ip",
"--system-dns",
"--traceroute",
"--unprivileged",
"--version",
"--version-all",
"--version-light",
"--version-trace",
"--webxml",
):
for opt in (
"--allports",
"--append-output",
"--badsum",
"--defeat-rst-ratelimit",
"--fuzzy",
"--help",
"--iflist",
"--log-errors",
"--no-stylesheet",
"--open",
"--osscan-guess",
"--osscan-limit",
"--packet-trace",
"--privileged",
"-r",
"-R",
"--randomize-hosts",
"--reason",
"--release-memory",
"--script-trace",
"--script-updatedb",
"--send-eth",
"--send-ip",
"--system-dns",
"--traceroute",
"--unprivileged",
"--version",
"--version-all",
"--version-light",
"--version-trace",
"--webxml",
):
if self[opt]:
opt_list.append(opt)
for opt in (\
"-b",
"-D",
"--datadir",
"--data-length",
"--dns-servers",
"-e",
"--exclude",
"--excludefile",
"-g",
"--ip-options",
"--mtu",
"--port-ratio",
"-S",
"--scanflags",
"--script",
"--script-args",
"--script-help",
"--servicedb",
"--spoof-mac",
"--stylesheet",
"--top-ports",
"--ttl",
"--versiondb",
"--version-intensity",
):
for opt in (
"-b",
"-D",
"--datadir",
"--data-length",
"--dns-servers",
"-e",
"--exclude",
"--excludefile",
"-g",
"--ip-options",
"--mtu",
"--port-ratio",
"-S",
"--scanflags",
"--script",
"--script-args",
"--script-help",
"--servicedb",
"--spoof-mac",
"--stylesheet",
"--top-ports",
"--ttl",
"--versiondb",
"--version-intensity",
):
if self[opt] is not None:
opt_list.extend((opt, self[opt]))

View File

@@ -133,15 +133,16 @@ class RecentScans(object):
except:
self.recent_scans_file = False
if self.recent_scans_file and \
(access(self.recent_scans_file, R_OK and W_OK) or \
access(dirname(self.recent_scans_file), R_OK and W_OK)):
if (self.recent_scans_file and
(access(self.recent_scans_file, R_OK and W_OK) or
access(dirname(self.recent_scans_file), R_OK and W_OK))):
self.using_file = True
# Recovering saved targets
recent_file = open(self.recent_scans_file, "r")
self.temp_list = [t for t in recent_file.read().split(";") \
if t != "" and t != "\n"]
self.temp_list = [
t for t in recent_file.read().split(";")
if t != "" and t != "\n"]
recent_file.close()
else:
self.using_file = False

View File

@@ -233,19 +233,19 @@ def parse_script_args_dict(raw_argument):
if __name__ == '__main__':
TESTS = (
('', []),
('a=b,c=d', [('a', 'b'), ('c', 'd')]),
('a="b=c"', [('a', '"b=c"')]),
('a="def\\"ghi"', [('a', '"def\\"ghi"')]),
('a={one,{two,{three}}}', [('a', '{one,{two,{three}}}')]),
('a={"quoted}quoted"}', [('a', '{"quoted}quoted"}')]),
('a="unterminated', None),
('user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},'
'userdb=C:\\Some\\Path\\To\\File',
[('user', 'foo'), ('pass', '",{}=bar"'),
('whois', '{whodb=nofollow+ripe}'),
('userdb', 'C:\\Some\\Path\\To\\File')]),
)
('', []),
('a=b,c=d', [('a', 'b'), ('c', 'd')]),
('a="b=c"', [('a', '"b=c"')]),
('a="def\\"ghi"', [('a', '"def\\"ghi"')]),
('a={one,{two,{three}}}', [('a', '{one,{two,{three}}}')]),
('a={"quoted}quoted"}', [('a', '{"quoted}quoted"}')]),
('a="unterminated', None),
('user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},'
'userdb=C:\\Some\\Path\\To\\File',
[('user', 'foo'), ('pass', '",{}=bar"'),
('whois', '{whodb=nofollow+ripe}'),
('userdb', 'C:\\Some\\Path\\To\\File')]),
)
for test, expected in TESTS:
args_dict = parse_script_args_dict(test)

View File

@@ -277,11 +277,9 @@ class SearchResult(object):
log.debug("Match profile: %s" % profile)
log.debug("Comparing: %s == %s ??" % (
str(self.parsed_scan.profile_name).lower(),
"*%s*" % profile.lower()))
if profile == "*" or profile == "" or \
profile.lower() in str(self.parsed_scan.profile_name).lower():
return True
return False
"*%s*" % profile.lower()))
return (profile == "*" or profile == "" or
profile.lower() in str(self.parsed_scan.profile_name).lower())
def match_option(self, option):
log.debug("Match option: %s" % option)
@@ -535,9 +533,9 @@ class SearchDir(SearchResult, object):
log.debug(">>> SearchDir initialized")
self.search_directory = search_directory
if type(file_extensions) in StringTypes:
if isinstance(file_extensions, StringTypes):
self.file_extensions = file_extensions.split(";")
elif type(file_extensions) == type([]):
elif isinstance(file_extensions, list):
self.file_extensions = file_extensions
else:
raise Exception(

View File

@@ -134,15 +134,16 @@ class TargetList(object):
self.target_list_file = False
#import pdb; pdb.set_trace()
if self.target_list_file and \
(access(self.target_list_file, R_OK and W_OK) or \
access(dirname(self.target_list_file), R_OK and W_OK)):
if (self.target_list_file and
(access(self.target_list_file, R_OK and W_OK) or
access(dirname(self.target_list_file), R_OK and W_OK))):
self.using_file = True
# Recovering saved targets
target_file = open(self.target_list_file, "r")
self.temp_list = [t for t in target_file.read().split(";") \
if t != "" and t != "\n"]
self.temp_list = [
t for t in target_file.read().split(";")
if t != "" and t != "\n"]
target_file.close()
else:
self.using_file = False

View File

@@ -173,7 +173,7 @@ class SearchConfig(UmitConfigParser, object):
config_parser.set(self.section_name, p_name, value)
def boolean_sanity(self, attr):
if attr == True or \
if attr is True or \
attr == "True" or \
attr == "true" or \
attr == "1":
@@ -192,18 +192,18 @@ class SearchConfig(UmitConfigParser, object):
return self._get_it("file_extension", "xml").split(";")
def set_file_extension(self, file_extension):
if type(file_extension) == type([]):
if isinstance(file_extension, list):
self._set_it("file_extension", ";".join(file_extension))
elif type(file_extension) in StringTypes:
elif isinstance(file_extension, StringTypes):
self._set_it("file_extension", file_extension)
def get_save_time(self):
return self._get_it("save_time", "60;days").split(";")
def set_save_time(self, save_time):
if type(save_time) == type([]):
if isinstance(save_time, list):
self._set_it("save_time", ";".join(save_time))
elif type(save_time) in StringTypes:
elif isinstance(save_time, StringTypes):
self._set_it("save_time", save_time)
def get_store_results(self):
@@ -413,8 +413,8 @@ class CommandProfile (Profile, object):
self._set_it(profile, 'description', description)
def get_profile(self, profile_name):
return {'profile': profile_name, \
'command': self.get_command(profile_name), \
return {'profile': profile_name,
'command': self.get_command(profile_name),
'description': self.get_description(profile_name)}
@@ -428,10 +428,9 @@ class NmapOutputHighlight(object):
property_name = "%s_highlight" % p_name
try:
return self.sanity_settings([config_parser.get(property_name,
prop,
True) \
for prop in self.setts])
return self.sanity_settings([
config_parser.get(
property_name, prop, True) for prop in self.setts])
except:
settings = []
prop_settings = self.default_highlights[p_name]
@@ -450,8 +449,8 @@ class NmapOutputHighlight(object):
property_name = "%s_highlight" % property_name
settings = self.sanity_settings(list(settings))
[config_parser.set(property_name, self.setts[pos], settings[pos]) \
for pos in xrange(len(settings))]
for pos in xrange(len(settings)):
config_parser.set(property_name, self.setts[pos], settings[pos])
def sanity_settings(self, settings):
"""This method tries to convert insane settings to sanity ones ;-)
@@ -481,7 +480,7 @@ class NmapOutputHighlight(object):
return settings
def boolean_sanity(self, attr):
if attr == True or attr == "True" or attr == "true" or attr == "1":
if attr is True or attr == "True" or attr == "true" or attr == "1":
return 1
return 0
@@ -546,7 +545,7 @@ class NmapOutputHighlight(object):
return True
def set_enable(self, enable):
if enable == False or enable == "0" or enable is None or enable == "":
if enable is False or enable == "0" or enable is None or enable == "":
config_parser.set(
"output_highlight", "enable_highlight", str(False))
else:

View File

@@ -218,9 +218,9 @@ class About(HIGDialog):
self.vbox.pack_start(entry)
entry = _program_entry(APP_DISPLAY_NAME, APP_WEB_SITE, _(
"%s is a multi-platform graphical %s frontend and results viewer. "
"It was originally derived from %s.") % (
APP_DISPLAY_NAME, NMAP_DISPLAY_NAME, UMIT_DISPLAY_NAME))
"%s is a multi-platform graphical %s frontend and results viewer. "
"It was originally derived from %s.") % (
APP_DISPLAY_NAME, NMAP_DISPLAY_NAME, UMIT_DISPLAY_NAME))
self.vbox.pack_start(entry)
entry = _program_entry(UMIT_DISPLAY_NAME, UMIT_WEB_SITE, _(

View File

@@ -130,7 +130,7 @@ from zenmapCore.UmitConf import is_maemo
from zenmapCore.UmitLogging import log
icon_names = (
# Operating Systems
# Operating Systems
'default',
'freebsd',
'irix',
@@ -142,7 +142,7 @@ icon_names = (
'ubuntu',
'unknown',
'win',
# Vulnerability Levels
# Vulnerability Levels
'vl_1',
'vl_2',
'vl_3',

View File

@@ -246,7 +246,7 @@ class ScanWindow(UmitScanWindow):
except:
about_icon = None
self.main_actions = [ \
self.main_actions = [
# Top level
('Scan', None, _('Sc_an'), None),
@@ -580,7 +580,7 @@ class ScanWindow(UmitScanWindow):
if widget is None:
# Don't have a Print menu item for lack of support.
return
entry = self.scan_interface.scan_result.scan_result_notebook.nmap_output.get_active_entry()
entry = self.scan_interface.scan_result.scan_result_notebook.nmap_output.get_active_entry() # noqa
widget.set_sensitive(entry is not None)
def _load_recent_scan(self, widget):
@@ -771,8 +771,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
try:
scan_interface.inventory.save_to_file(
saved_filename, selected_index, format)
scan_interface.inventory.get_scans()[selected_index].unsaved = \
False
scan_interface.inventory.get_scans()[selected_index].unsaved = False # noqa
except (OSError, IOError), e:
alert = HIGAlertDialog(
message_format=_("Can't save file"),
@@ -916,7 +915,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
def _print_cb(self, *args):
"""Show a print dialog."""
entry = self.scan_interface.scan_result.scan_result_notebook.nmap_output.get_active_entry()
entry = self.scan_interface.scan_result.scan_result_notebook.nmap_output.get_active_entry() # noqa
if entry is None:
return False
zenmapGUI.Print.run_print_operation(

View File

@@ -297,7 +297,7 @@ class HighlightProperty(object):
"clicked", self.highlight_color_dialog_ok, color_dialog)
color_dialog.cancel_button.connect(
"clicked", self.highlight_color_dialog_cancel,
color_dialog)
color_dialog)
color_dialog.connect(
"delete-event", self.highlight_color_dialog_close,
color_dialog)

View File

@@ -372,7 +372,8 @@ class NmapOutputViewer (gtk.VBox):
buf.insert(buf.get_end_iter(), new_output)
# Highlight the new text.
self.apply_highlighting(
buf.get_iter_at_mark(prev_end_mark), buf.get_end_iter())
buf.get_iter_at_mark(prev_end_mark),
buf.get_end_iter())
except MemoryError:
self.show_large_output_message(self.command_execution)
return

View File

@@ -145,19 +145,19 @@ from zenmapGUI.ScriptInterface import *
def get_option_check_auxiliary_widget(option, ops, check):
if option in ("-sI", "-b", "--script", "--script-args", "--exclude", "-p",
"-D", "-S", "--source-port", "-e", "--ttl", "-iR", "--max-retries",
"--host-timeout", "--max-rtt-timeout", "--min-rtt-timeout",
"--initial-rtt-timeout", "--max-hostgroup", "--min-hostgroup",
"--max-parallelism", "--min-parallelism", "--max-scan-delay",
"--scan-delay", "-PA", "-PS", "-PU", "-PO", "-PY"):
"-D", "-S", "--source-port", "-e", "--ttl", "-iR", "--max-retries",
"--host-timeout", "--max-rtt-timeout", "--min-rtt-timeout",
"--initial-rtt-timeout", "--max-hostgroup", "--min-hostgroup",
"--max-parallelism", "--min-parallelism", "--max-scan-delay",
"--scan-delay", "-PA", "-PS", "-PU", "-PO", "-PY"):
return OptionEntry(option, ops, check)
elif option in ("-d", "-v"):
return OptionLevel(option, ops, check)
elif option in ("--excludefile", "-iL"):
return OptionFile(option, ops, check)
elif option in ("-A", "-O", "-sV", "-n", "-6", "-Pn", "-PE", "-PP", "-PM",
"-PB", "-sC", "--script-trace", "-F", "-f", "--packet-trace", "-r",
"--traceroute"):
"-PB", "-sC", "--script-trace", "-F", "-f", "--packet-trace", "-r",
"--traceroute"):
return None
elif option in ("",):
return OptionExtras(option, ops, check)
@@ -496,9 +496,8 @@ class OptionBuilder(object):
return dic
def __parse_groups(self):
return [g_name.getAttribute(u'name') for g_name in \
self.xml.getElementsByTagName(u'groups')[0].\
getElementsByTagName(u'group')]
return [g_name.getAttribute(u'name') for g_name in
self.xml.getElementsByTagName(u'groups')[0].getElementsByTagName(u'group')] # noqa
def __parse_tabs(self):
dic = {}

View File

@@ -342,7 +342,7 @@ class ProfileEditor(HIGWindow):
log.debug(">>> Tab name: %s" % tab_name)
log.debug(">>>Creating profile editor section: %s" % section_name)
vbox = HIGVBox()
if tab.notscripttab: # if notscripttab is set
if tab.notscripttab: # if notscripttab is set
table = HIGTable()
table.set_row_spacings(2)
section = HIGSectionLabel(section_name)
@@ -374,13 +374,14 @@ class ProfileEditor(HIGWindow):
command = self.ops.render_string()
buf = self.profile_description_text.get_buffer()
description = buf.get_text(buf.get_start_iter(),\
buf.get_end_iter())
description = buf.get_text(
buf.get_start_iter(), buf.get_end_iter())
try:
self.profile.add_profile(profile_name,\
command=command,\
description=description)
self.profile.add_profile(
profile_name,
command=command,
description=description)
except ValueError:
alert = HIGAlertDialog(
message_format=_('Disallowed profile name'),

View File

@@ -323,7 +323,7 @@ class ScanInterface(HIGVBox):
def go_to_host(self, hostname):
"""Scroll the text output to the appearance of the named host."""
self.scan_result.scan_result_notebook.nmap_output.nmap_output.go_to_host(hostname)
self.scan_result.scan_result_notebook.nmap_output.nmap_output.go_to_host(hostname) # noqa
def __create_toolbar(self):
self.toolbar = ScanToolbar()
@@ -456,7 +456,7 @@ class ScanInterface(HIGVBox):
def update_cancel_button(self):
"""Make the Cancel button sensitive or not depending on whether the
currently displayed scan is running."""
entry = self.scan_result.scan_result_notebook.nmap_output.get_active_entry()
entry = self.scan_result.scan_result_notebook.nmap_output.get_active_entry() # noqa
if entry is None:
self.toolbar.cancel_button.set_sensitive(False)
else:
@@ -464,7 +464,7 @@ class ScanInterface(HIGVBox):
def _cancel_scan_cb(self, widget):
"""Cancel the scan whose output is shown."""
entry = self.scan_result.scan_result_notebook.nmap_output.get_active_entry()
entry = self.scan_result.scan_result_notebook.nmap_output.get_active_entry() # noqa
if entry is not None and entry.running:
self.cancel_scan(entry.command)
@@ -472,14 +472,14 @@ class ScanInterface(HIGVBox):
"""This is like _cancel_scan_cb, but it cancels the scans that are
currently selected in the scans list, not the one whose output is
currently shown."""
model, selection = self.scan_result.scan_result_notebook.scans_list.scans_list.get_selection().get_selected_rows()
model, selection = self.scan_result.scan_result_notebook.scans_list.scans_list.get_selection().get_selected_rows() # noqa
for path in selection:
entry = model.get_value(model.get_iter(path), 0)
if entry.running:
self.cancel_scan(entry.command)
def _remove_scan_cb(self, widget):
model, selection = self.scan_result.scan_result_notebook.scans_list.scans_list.get_selection().get_selected_rows()
model, selection = self.scan_result.scan_result_notebook.scans_list.scans_list.get_selection().get_selected_rows() # noqa
selected_refs = []
for path in selection:
# Kill running scans and remove finished scans from the inventory.
@@ -656,7 +656,7 @@ class ScanInterface(HIGVBox):
try:
parsed.nmap_output = command.get_output()
except MemoryError:
self.scan_result.scan_result_notebook.nmap_output.nmap_output.show_large_output_message(command)
self.scan_result.scan_result_notebook.nmap_output.nmap_output.show_large_output_message(command) # noqa
self.update_ui()
self.scans_store.finish_running_scan(command, parsed)
@@ -839,7 +839,8 @@ class ScanInterface(HIGVBox):
host.comment = comment
for scan in self.inventory.get_scans():
for h in scan.get_hosts():
if h.get_ip() == host.get_ip() and h.get_ipv6() == host.get_ipv6():
if (h.get_ip() == host.get_ip() and
h.get_ipv6() == host.get_ipv6()):
h.set_comment(host.comment)
scan.unsaved = True
break
@@ -929,10 +930,10 @@ class ScanResult(gtk.HPaned):
self.pack2(self.scan_result_notebook, True, False)
def set_nmap_output(self, msg):
self.scan_result_notebook.nmap_output.nmap_output.text_view.get_buffer().set_text(msg)
self.scan_result_notebook.nmap_output.nmap_output.text_view.get_buffer().set_text(msg) # noqa
def clear_nmap_output(self):
self.scan_result_notebook.nmap_output.nmap_output.text_view.get_buffer().set_text("")
self.scan_result_notebook.nmap_output.nmap_output.text_view.get_buffer().set_text("") # noqa
def get_host_selection(self):
return self.scan_host_view.host_view.get_selection()

View File

@@ -358,8 +358,8 @@ class HostOpenPorts(HIGVBox):
self.port_columns['hostname'].set_visible(False)
self.scroll_ports_hosts.set_policy(gtk.POLICY_AUTOMATIC,\
gtk.POLICY_AUTOMATIC)
self.scroll_ports_hosts.set_policy(
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
def port_mode(self):
child = self.scroll_ports_hosts.get_child()

View File

@@ -313,16 +313,16 @@ class ScriptInterface:
status = process.scan_state()
except:
status = None
log.debug("Script interface: script_list_timer_callback %s" % \
log.debug("Script interface: script_list_timer_callback %s" %
repr(status))
if status == True:
if status is True:
# Still running, schedule this timer to check again.
return True
self.script_list_widget.set_sensitive(True)
if status == False:
if status is False:
# Finished with success.
callback(True, process)
else:

View File

@@ -167,8 +167,8 @@ class HIGAlertDialog(gtk.MessageDialog):
# "Alert windows have no titles, as the title would usually
# unnecessarily duplicate the alert's primary text"
self.set_title("")
self.set_markup("<span weight='bold'size='larger'>%s</span>" \
% message_format)
self.set_markup(
"<span weight='bold'size='larger'>%s</span>" % message_format)
if secondary_text:
# GTK up to version 2.4 does not have secondary_text
try:

View File

@@ -198,15 +198,11 @@ class HIGSpinnerImages:
self.animated_pixbufs = new_animated
for k in self.static_pixbufs:
self.static_pixbufs[k] = self.static_pixbufs[k].\
scale_simple(width,
height,
gtk.gdk.INTERP_BILINEAR)
self.static_pixbufs[k] = self.static_pixbufs[k].scale_simple(
width, height, gtk.gdk.INTERP_BILINEAR)
self.rest_pixbuf = self.rest_pixbuf.\
scale_simple(width,
height,
gtk.gdk.INTERP_BILINEAR)
self.rest_pixbuf = self.rest_pixbuf.scale_simple(
width, height, gtk.gdk.INTERP_BILINEAR)
self.images_width = width
self.images_height = height
@@ -275,8 +271,8 @@ class HIGSpinnerCache:
for x in range(0, grid_width, size):
for y in range(0, grid_height, size):
self.spinner_images.add_animated_pixbuf(\
self.__extract_frame(grid_pixbuf, x, y, size, size))
self.spinner_images.add_animated_pixbuf(
self.__extract_frame(grid_pixbuf, x, y, size, size))
def load_static_from_lookup(self, icon_name="gnome-spinner-rest",
key_name=None):