1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-24 00:19:01 +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

@@ -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):