mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Merge #2088: Update Zenmap to Python 3 and PyGObject
Note: Ndiff build will be broken until subsequent changes are made. Deprecation warnings will need to be addressed in future changes. Closes #2088
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o [GH#2088][GH#1176][Zenmap] Updated Zenmap to Python 3 and PyGObject. [Jakub Kulík]
|
||||
|
||||
o [GH#2541] UDP port scan (-sU) and version scan (-sV) now both use the same
|
||||
data source, nmap-service-probes, for data payloads. Previously, the
|
||||
nmap-payloads file was used for port scan. Port scan responses will be used
|
||||
|
||||
20
configure.ac
20
configure.ac
@@ -230,23 +230,19 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
|
||||
dnl Check IPv6 raw sending flavor.
|
||||
CHECK_IPV6_IPPROTO_RAW
|
||||
|
||||
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],[python2 python2.7 python2.6 python2.5 python2.4 python])
|
||||
AM_PATH_PYTHON([2.4], [HAVE_PYTHON=true], [HAVE_PYTHON=false])
|
||||
HAVE_PYTHON2=false
|
||||
if test $HAVE_PYTHON && test "x${PYTHON_VERSION%%.*}" = "x2"; then
|
||||
HAVE_PYTHON2=true
|
||||
fi
|
||||
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],[python3 python])
|
||||
AM_PATH_PYTHON([3], [HAVE_PYTHON=true], [HAVE_PYTHON=false])
|
||||
|
||||
NDIFFDIR=ndiff
|
||||
|
||||
# Do they want Ndiff?
|
||||
AC_ARG_WITH(ndiff, AC_HELP_STRING([--without-ndiff], [Skip installation of the Ndiff utility]), [], [with_ndiff=check])
|
||||
if $HAVE_PYTHON2 ; then : ;
|
||||
if $HAVE_PYTHON ; then : ;
|
||||
else
|
||||
if test "$with_ndiff" = "check" ; then
|
||||
AC_MSG_WARN([Not building Ndiff because Python 2.x with x>=4 was not found])
|
||||
AC_MSG_WARN([Not building Ndiff because Python was not found])
|
||||
elif test "$with_ndiff" = "yes"; then
|
||||
AC_MSG_FAILURE([--with-ndiff requires Python 2.x with x>=4])
|
||||
AC_MSG_FAILURE([--with-ndiff requires Python])
|
||||
fi
|
||||
with_ndiff=no
|
||||
fi
|
||||
@@ -280,12 +276,12 @@ ZENMAPDIR=zenmap
|
||||
# Do they want Zenmap?
|
||||
AC_ARG_WITH(zenmap, AC_HELP_STRING([--without-zenmap], [Skip installation of the Zenmap graphical frontend]), [], [with_zenmap=check])
|
||||
|
||||
if $HAVE_PYTHON2 ; then : ;
|
||||
if $HAVE_PYTHON ; then : ;
|
||||
else
|
||||
if test "$with_zenmap" = "check"; then
|
||||
AC_MSG_WARN([Not building Zenmap because Python 2.x with x>=4 was not found])
|
||||
AC_MSG_WARN([Not building Zenmap because Python was not found])
|
||||
elif test "$with_zenmap" = "yes"; then
|
||||
AC_MSG_FAILURE([--with-zenmap requires Python 2.x with x>=4])
|
||||
AC_MSG_FAILURE([--with-zenmap requires Python])
|
||||
fi
|
||||
with_zenmap=no
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -75,7 +74,7 @@ NAME_PY = os.path.join("zenmapCore", "Name.py")
|
||||
|
||||
def update_date(base_dir):
|
||||
name_file = os.path.join(base_dir, NAME_PY)
|
||||
print ">>> Updating %s" % name_file
|
||||
print(">>> Updating %s" % name_file)
|
||||
nf = open(name_file, "r")
|
||||
ncontent = nf.read()
|
||||
nf.close()
|
||||
@@ -89,22 +88,22 @@ def update_date(base_dir):
|
||||
|
||||
|
||||
def update_version(base_dir, version):
|
||||
print ">>> Updating %s" % os.path.join(base_dir, VERSION)
|
||||
print(">>> Updating %s" % os.path.join(base_dir, VERSION))
|
||||
vf = open(os.path.join(base_dir, VERSION), "wb")
|
||||
print >> vf, version
|
||||
print(version, file=vf)
|
||||
vf.close()
|
||||
print ">>> Updating %s" % os.path.join(base_dir, VERSION_PY)
|
||||
print(">>> Updating %s" % os.path.join(base_dir, VERSION_PY))
|
||||
vf = open(os.path.join(base_dir, VERSION_PY), "w")
|
||||
print >> vf, "VERSION = \"%s\"" % version
|
||||
print("VERSION = \"%s\"" % version, file=vf)
|
||||
vf.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print >> sys.stderr, "Usage: %s <version>" % sys.argv[0]
|
||||
print("Usage: %s <version>" % sys.argv[0], file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1]
|
||||
print ">>> Updating version number to \"%s\"" % version
|
||||
print(">>> Updating version number to \"%s\"" % version)
|
||||
update_version(".", version)
|
||||
update_date(".")
|
||||
|
||||
@@ -57,9 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gtk.gtk_version
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gi.version_info
|
||||
|
||||
#from boxes import BWHBox, BWVBox, BWTable, BWStatusbar, BWScrolledWindow
|
||||
#from buttons import BWStockButton, BWToggleStockButton
|
||||
|
||||
@@ -57,13 +57,16 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
__all__ = ('BWBox', 'BWHBox', 'BWVBox',
|
||||
'BWStatusbar', 'BWTable', 'BWScrolledWindow')
|
||||
|
||||
|
||||
class BWBox(gtk.Box):
|
||||
class BWBox(Gtk.Box):
|
||||
"""
|
||||
"""
|
||||
def bw_pack_start_expand_fill(self, widget, padding=0):
|
||||
@@ -97,40 +100,44 @@ class BWBox(gtk.Box):
|
||||
self.pack_end(widget, False, False, padding)
|
||||
|
||||
|
||||
class BWHBox(gtk.HBox, BWBox):
|
||||
class BWHBox(BWBox):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
"""
|
||||
"""
|
||||
gtk.HBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
|
||||
class BWVBox(gtk.VBox, BWBox):
|
||||
class BWVBox(BWBox):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
"""
|
||||
"""
|
||||
gtk.VBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
|
||||
class BWStatusbar(gtk.Statusbar, BWBox):
|
||||
class BWStatusbar(Gtk.Statusbar, BWBox):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
"""
|
||||
"""
|
||||
gtk.HBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
|
||||
class BWTable(gtk.Table, BWBox):
|
||||
class BWTable(Gtk.Table, BWBox):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, rows=1, columns=1, homogeneous=False):
|
||||
"""
|
||||
"""
|
||||
gtk.Table.__init__(self, rows, columns, homogeneous)
|
||||
Gtk.Table.__init__(self, n_rows=rows, n_columns=columns,
|
||||
homogeneous=homogeneous)
|
||||
self.bw_set_spacing(12)
|
||||
|
||||
self.__rows = rows
|
||||
@@ -154,8 +161,8 @@ class BWTable(gtk.Table, BWBox):
|
||||
|
||||
def bw_attach_next(self,
|
||||
child,
|
||||
xoptions=gtk.EXPAND | gtk.FILL,
|
||||
yoptions=gtk.EXPAND | gtk.FILL,
|
||||
xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
||||
yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
|
||||
xpadding=0,
|
||||
ypadding=0):
|
||||
"""
|
||||
@@ -185,13 +192,13 @@ class BWTable(gtk.Table, BWBox):
|
||||
self.__last_point = (row, column)
|
||||
|
||||
|
||||
class BWScrolledWindow(gtk.ScrolledWindow):
|
||||
class BWScrolledWindow(Gtk.ScrolledWindow):
|
||||
"""
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
"""
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||
Gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
self.set_border_width(6)
|
||||
|
||||
@@ -57,34 +57,37 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class BWStockButton(gtk.Button):
|
||||
class BWStockButton(Gtk.Button):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, stock, text=None, size=gtk.ICON_SIZE_BUTTON):
|
||||
def __init__(self, stock, text=None, size=Gtk.IconSize.BUTTON):
|
||||
"""
|
||||
"""
|
||||
gtk.Button.__init__(self, text)
|
||||
Gtk.Button.__init__(self, label=text)
|
||||
|
||||
self.__size = size
|
||||
|
||||
self.__image = gtk.Image()
|
||||
self.__image = Gtk.Image()
|
||||
self.__image.set_from_stock(stock, self.__size)
|
||||
self.set_image(self.__image)
|
||||
|
||||
|
||||
class BWToggleStockButton(gtk.ToggleButton):
|
||||
class BWToggleStockButton(Gtk.ToggleButton):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, stock, text=None, size=gtk.ICON_SIZE_BUTTON):
|
||||
def __init__(self, stock, text=None, size=Gtk.IconSize.BUTTON):
|
||||
"""
|
||||
"""
|
||||
gtk.ToggleButton.__init__(self, text)
|
||||
Gtk.ToggleButton.__init__(self, label=text)
|
||||
|
||||
self.__size = size
|
||||
|
||||
self.__image = gtk.Image()
|
||||
self.__image = Gtk.Image()
|
||||
self.__image.set_from_stock(stock, self.__size)
|
||||
self.set_image(self.__image)
|
||||
|
||||
@@ -57,19 +57,21 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
|
||||
class BWChangeableComboBoxEntry(gtk.ComboBoxEntry):
|
||||
class BWChangeableComboBoxEntry(Gtk.ComboBoxText):
|
||||
"""
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
"""
|
||||
self.__liststore = gtk.ListStore(gobject.TYPE_STRING)
|
||||
self.__liststore = Gtk.ListStore.new([str])
|
||||
|
||||
gtk.ComboBoxEntry.__init__(self, self.__liststore, 0)
|
||||
Gtk.ComboBoxText.__init__(self, model=self.__liststore, has_entry=True)
|
||||
|
||||
self.connect("changed", self.__changed)
|
||||
self.get_child().connect("changed", self.__entry_changed)
|
||||
@@ -114,22 +116,22 @@ if __name__ == "__main__":
|
||||
"""
|
||||
combo.append_text('New')
|
||||
|
||||
window = gtk.Window()
|
||||
window.connect("destroy", lambda w: gtk.main_quit())
|
||||
window = Gtk.Window()
|
||||
window.connect("destroy", lambda w: Gtk.main_quit())
|
||||
|
||||
box = gtk.HBox()
|
||||
box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||
|
||||
combo = BWChangeableComboBoxEntry()
|
||||
combo.append_text('New')
|
||||
combo.set_active(0)
|
||||
|
||||
button = gtk.Button('More')
|
||||
button = Gtk.Button.new_with_label('More')
|
||||
button.connect("clicked", button_clicked, combo)
|
||||
|
||||
box.pack_start(button, False, False)
|
||||
box.pack_start(combo, True, True)
|
||||
box.pack_start(button, False, False, 0)
|
||||
box.pack_start(combo, True, True, 0)
|
||||
|
||||
window.add(box)
|
||||
window.show_all()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -57,22 +57,25 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
from radialnet.bestwidgets.labels import BWSectionLabel
|
||||
|
||||
|
||||
class BWExpander(gtk.Expander):
|
||||
class BWExpander(Gtk.Expander):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, label=''):
|
||||
"""
|
||||
"""
|
||||
gtk.Expander.__init__(self)
|
||||
Gtk.Expander.__init__(self)
|
||||
|
||||
self.__label = BWSectionLabel(label)
|
||||
self.set_label_widget(self.__label)
|
||||
|
||||
self.__alignment = gtk.Alignment(0, 0, 1, 1)
|
||||
self.__alignment = Gtk.Alignment.new(0, 0, 1, 1)
|
||||
self.__alignment.set_padding(12, 0, 24, 0)
|
||||
|
||||
self.add(self.__alignment)
|
||||
|
||||
@@ -57,21 +57,24 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
|
||||
class BWFrame(gtk.Frame):
|
||||
class BWFrame(Gtk.Frame):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, label=''):
|
||||
"""
|
||||
"""
|
||||
gtk.Frame.__init__(self)
|
||||
Gtk.Frame.__init__(self)
|
||||
|
||||
self.set_border_width(3)
|
||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
|
||||
self.__alignment = gtk.Alignment(0, 0, 1, 1)
|
||||
self.__alignment = Gtk.Alignment.new(0, 0, 1, 1)
|
||||
self.__alignment.set_padding(12, 0, 24, 0)
|
||||
|
||||
self.add(self.__alignment)
|
||||
|
||||
@@ -57,33 +57,36 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class BWLabel(gtk.Label):
|
||||
class BWLabel(Gtk.Label):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, text=''):
|
||||
"""
|
||||
"""
|
||||
gtk.Label.__init__(self)
|
||||
Gtk.Label.__init__(self)
|
||||
|
||||
self.set_text(text)
|
||||
self.set_justify(gtk.JUSTIFY_LEFT)
|
||||
self.set_justify(Gtk.Justification.LEFT)
|
||||
self.set_alignment(0, 0.50)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class BWSectionLabel(gtk.Label):
|
||||
class BWSectionLabel(Gtk.Label):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, text=''):
|
||||
"""
|
||||
"""
|
||||
gtk.Label.__init__(self)
|
||||
Gtk.Label.__init__(self)
|
||||
|
||||
self.set_markup('<b>' + text + '</b>')
|
||||
self.set_justify(gtk.JUSTIFY_LEFT)
|
||||
self.set_justify(Gtk.Justification.LEFT)
|
||||
self.set_alignment(0, 0.50)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
@@ -57,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
from radialnet.bestwidgets.boxes import *
|
||||
|
||||
|
||||
@@ -76,8 +79,8 @@ class BWTextView(BWScrolledWindow):
|
||||
def __create_widgets(self):
|
||||
"""
|
||||
"""
|
||||
self.__textbuffer = gtk.TextBuffer()
|
||||
self.__textview = gtk.TextView(self.__textbuffer)
|
||||
self.__textbuffer = Gtk.TextBuffer()
|
||||
self.__textview = Gtk.TextView.new_with_buffer(self.__textbuffer)
|
||||
|
||||
self.add_with_viewport(self.__textview)
|
||||
|
||||
@@ -128,7 +131,7 @@ class BWTextEditor(BWScrolledWindow):
|
||||
"""
|
||||
"""
|
||||
BWScrolledWindow.__init__(self)
|
||||
self.connect('expose_event', self.__expose)
|
||||
self.connect('draw', self.__draw)
|
||||
|
||||
self.__auto_scroll = False
|
||||
|
||||
@@ -139,12 +142,12 @@ class BWTextEditor(BWScrolledWindow):
|
||||
"""
|
||||
self.__hbox = BWHBox(spacing=6)
|
||||
|
||||
self.__textbuffer = gtk.TextBuffer()
|
||||
self.__textview = gtk.TextView(self.__textbuffer)
|
||||
self.__textbuffer = Gtk.TextBuffer()
|
||||
self.__textview = Gtk.TextView.new_with_buffer(self.__textbuffer)
|
||||
|
||||
self.__linebuffer = gtk.TextBuffer()
|
||||
self.__lineview = gtk.TextView(self.__linebuffer)
|
||||
self.__lineview.set_justification(gtk.JUSTIFY_RIGHT)
|
||||
self.__linebuffer = Gtk.TextBuffer()
|
||||
self.__lineview = Gtk.TextView.new_with_buffer(self.__linebuffer)
|
||||
self.__lineview.set_justification(Gtk.Justification.RIGHT)
|
||||
self.__lineview.set_editable(False)
|
||||
self.__lineview.set_sensitive(False)
|
||||
|
||||
@@ -153,7 +156,7 @@ class BWTextEditor(BWScrolledWindow):
|
||||
|
||||
self.add_with_viewport(self.__hbox)
|
||||
|
||||
def __expose(self, widget, event):
|
||||
def __draw(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
# code to fix a gtk issue that don't show text correctly
|
||||
|
||||
@@ -57,21 +57,24 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
from radialnet.bestwidgets import gtk_version_minor
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
PRIMARY_TEXT_MARKUP = '<span weight="bold" size="larger">%s</span>'
|
||||
|
||||
|
||||
class BWAlertDialog(gtk.MessageDialog):
|
||||
class BWAlertDialog(Gtk.MessageDialog):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, parent=None, flags=0, type=gtk.MESSAGE_INFO,
|
||||
buttons=gtk.BUTTONS_OK,
|
||||
def __init__(self, parent=None, flags=0, type=Gtk.MessageType.INFO,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
primary_text=None,
|
||||
secondary_text=None):
|
||||
|
||||
gtk.MessageDialog.__init__(self, parent, flags, type, buttons)
|
||||
Gtk.MessageDialog.__init__(self, parent=parent, flags=flags,
|
||||
message_type=type, buttons=buttons)
|
||||
|
||||
self.connect('response', self.__destroy)
|
||||
|
||||
@@ -81,9 +84,6 @@ class BWAlertDialog(gtk.MessageDialog):
|
||||
self.set_markup(PRIMARY_TEXT_MARKUP % primary_text)
|
||||
|
||||
if secondary_text:
|
||||
|
||||
# GTK up to version 2.4 does not have secondary_text
|
||||
if gtk_version_minor > 4:
|
||||
self.format_secondary_text(secondary_text)
|
||||
|
||||
def __destroy(self, dialog, id):
|
||||
@@ -92,14 +92,14 @@ class BWAlertDialog(gtk.MessageDialog):
|
||||
self.destroy()
|
||||
|
||||
|
||||
class BWWindow(gtk.Window):
|
||||
class BWWindow(Gtk.Window):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, type=gtk.WINDOW_TOPLEVEL):
|
||||
def __init__(self, type=Gtk.WindowType.TOPLEVEL):
|
||||
"""
|
||||
"""
|
||||
gtk.Window.__init__(self, type)
|
||||
Gtk.Window.__init__(self, type=type)
|
||||
self.set_border_width(5)
|
||||
|
||||
|
||||
BWMainWindow = gtk.Window
|
||||
BWMainWindow = Gtk.Window
|
||||
|
||||
@@ -97,4 +97,4 @@ if __name__ == '__main__':
|
||||
|
||||
h = ArgvHandle(sys.argv)
|
||||
|
||||
print h.get_last_value()
|
||||
print(h.get_last_value())
|
||||
|
||||
@@ -206,5 +206,5 @@ if __name__ == "__main__":
|
||||
polar = PolarCoordinate(1, math.pi)
|
||||
cartesian = CartesianCoordinate(-1, 0)
|
||||
|
||||
print polar.to_cartesian()
|
||||
print cartesian.to_polar()
|
||||
print(polar.to_cartesian())
|
||||
print(cartesian.to_polar())
|
||||
|
||||
@@ -113,7 +113,7 @@ class Linear2DInterpolator:
|
||||
a_pass = 0
|
||||
b_pass = 0
|
||||
|
||||
self.__interpolated_points = range(number_of_pass)
|
||||
self.__interpolated_points = list(range(number_of_pass))
|
||||
|
||||
for i in range(0, number_of_pass):
|
||||
|
||||
@@ -138,7 +138,7 @@ class Linear2DInterpolator:
|
||||
a_pass = float(af - ai) / number_of_pass
|
||||
b_pass = float(bf - bi) / number_of_pass
|
||||
|
||||
self.__interpolated_points = range(number_of_pass)
|
||||
self.__interpolated_points = list(range(number_of_pass))
|
||||
|
||||
for i in range(1, number_of_pass + 1):
|
||||
self.__interpolated_points[i - 1] = (ai + a_pass * i,
|
||||
@@ -156,4 +156,4 @@ if __name__ == "__main__":
|
||||
i.set_start_point(0, 0)
|
||||
i.set_final_point(1, 1)
|
||||
|
||||
print len(i.get_points(10)), i.get_points(10)
|
||||
print(len(i.get_points(10)), i.get_points(10))
|
||||
|
||||
@@ -57,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from radialnet.util.integration import make_graph_from_nmap_parser
|
||||
from radialnet.core.Info import INFO
|
||||
@@ -111,9 +114,9 @@ class Application(BWMainWindow):
|
||||
|
||||
self.add(self.__vbox)
|
||||
self.set_title(" ".join([INFO['name'], INFO['version']]))
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
self.show_all()
|
||||
self.connect('destroy', gtk.main_quit)
|
||||
self.connect('destroy', Gtk.main_quit)
|
||||
|
||||
self.__radialnet.set_no_show_all(True)
|
||||
self.__control.set_no_show_all(True)
|
||||
@@ -155,4 +158,4 @@ class Application(BWMainWindow):
|
||||
def start(self):
|
||||
"""
|
||||
"""
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -57,9 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk, GObject
|
||||
|
||||
import math
|
||||
import gobject
|
||||
|
||||
import radialnet.util.geometry as geometry
|
||||
|
||||
@@ -107,14 +110,6 @@ class ControlWidget(BWVBox):
|
||||
self.bw_pack_start_noexpand_nofill(self.__view)
|
||||
|
||||
|
||||
def try_set_tooltip_text(widget, text):
|
||||
try:
|
||||
widget.set_tooltip_text(text)
|
||||
except AttributeError:
|
||||
# The set_tooltip_text method was introduced in PyGTK 2.12.
|
||||
pass
|
||||
|
||||
|
||||
class ControlAction(BWExpander):
|
||||
"""
|
||||
"""
|
||||
@@ -135,39 +130,35 @@ class ControlAction(BWExpander):
|
||||
self.__tbox.bw_set_spacing(0)
|
||||
self.__vbox = BWVBox()
|
||||
|
||||
self.__jump_to = gtk.RadioToolButton(None, gtk.STOCK_JUMP_TO)
|
||||
try_set_tooltip_text(self.__jump_to, 'Change focus')
|
||||
self.__jump_to = Gtk.RadioToolButton(group=None,
|
||||
stock_id=Gtk.STOCK_JUMP_TO)
|
||||
self.__jump_to.set_tooltip_text('Change focus')
|
||||
self.__jump_to.connect('toggled',
|
||||
self.__change_pointer,
|
||||
RadialNet.POINTER_JUMP_TO)
|
||||
|
||||
try:
|
||||
# gtk.STOCK_INFO is available only in PyGTK 2.8 and later.
|
||||
info_icon = gtk.STOCK_INFO
|
||||
except AttributeError:
|
||||
self.__info = gtk.RadioToolButton(self.__jump_to, None)
|
||||
self.__info.set_label(_("Info"))
|
||||
else:
|
||||
self.__info = gtk.RadioToolButton(self.__jump_to, info_icon)
|
||||
try_set_tooltip_text(self.__info, 'Show information')
|
||||
self.__info = Gtk.RadioToolButton(group=self.__jump_to,
|
||||
stock_id=Gtk.STOCK_INFO)
|
||||
self.__info.set_tooltip_text('Show information')
|
||||
self.__info.connect('toggled',
|
||||
self.__change_pointer,
|
||||
RadialNet.POINTER_INFO)
|
||||
|
||||
self.__group = gtk.RadioToolButton(self.__jump_to, gtk.STOCK_ADD)
|
||||
try_set_tooltip_text(self.__group, 'Group children')
|
||||
self.__group = Gtk.RadioToolButton(group=self.__jump_to,
|
||||
stock_id=Gtk.STOCK_ADD)
|
||||
self.__group.set_tooltip_text('Group children')
|
||||
self.__group.connect('toggled',
|
||||
self.__change_pointer,
|
||||
RadialNet.POINTER_GROUP)
|
||||
|
||||
self.__region = gtk.RadioToolButton(self.__jump_to,
|
||||
gtk.STOCK_SELECT_COLOR)
|
||||
try_set_tooltip_text(self.__region, 'Fill region')
|
||||
self.__region = Gtk.RadioToolButton(group=self.__jump_to,
|
||||
stock_id=Gtk.STOCK_SELECT_COLOR)
|
||||
self.__region.set_tooltip_text('Fill region')
|
||||
self.__region.connect('toggled',
|
||||
self.__change_pointer,
|
||||
RadialNet.POINTER_FILL)
|
||||
|
||||
self.__region_color = gtk.combo_box_new_text()
|
||||
self.__region_color = Gtk.ComboBoxText.new()
|
||||
self.__region_color.append_text(_('Red'))
|
||||
self.__region_color.append_text(_('Yellow'))
|
||||
self.__region_color.append_text(_('Green'))
|
||||
@@ -205,13 +196,13 @@ class ControlAction(BWExpander):
|
||||
self.radialnet.set_region_color(self.__region_color.get_active())
|
||||
|
||||
|
||||
class ControlVariableWidget(gtk.DrawingArea):
|
||||
class ControlVariableWidget(Gtk.DrawingArea):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, name, value, update, increment=1):
|
||||
"""
|
||||
"""
|
||||
gtk.DrawingArea.__init__(self)
|
||||
Gtk.DrawingArea.__init__(self)
|
||||
|
||||
self.__variable_name = name
|
||||
self.__value = value
|
||||
@@ -226,18 +217,17 @@ class ControlVariableWidget(gtk.DrawingArea):
|
||||
|
||||
self.__last_value = self.__value()
|
||||
|
||||
self.connect('expose_event', self.expose)
|
||||
self.connect('draw', self.draw)
|
||||
self.connect('button_press_event', self.button_press)
|
||||
self.connect('button_release_event', self.button_release)
|
||||
self.connect('motion_notify_event', self.motion_notify)
|
||||
|
||||
self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
|
||||
gtk.gdk.BUTTON_RELEASE_MASK |
|
||||
gtk.gdk.MOTION_NOTIFY |
|
||||
gtk.gdk.POINTER_MOTION_HINT_MASK |
|
||||
gtk.gdk.POINTER_MOTION_MASK)
|
||||
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
|
||||
Gdk.EventMask.BUTTON_RELEASE_MASK |
|
||||
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||
Gdk.EventMask.POINTER_MOTION_MASK)
|
||||
|
||||
gobject.timeout_add(REFRESH_RATE, self.verify_value)
|
||||
GLib.timeout_add(REFRESH_RATE, self.verify_value)
|
||||
|
||||
def verify_value(self):
|
||||
"""
|
||||
@@ -257,14 +247,14 @@ class ControlVariableWidget(gtk.DrawingArea):
|
||||
|
||||
if self.__button_is_clicked(pointer) and event.button == 1:
|
||||
|
||||
event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
|
||||
event.window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2))
|
||||
self.__active_increment = True
|
||||
self.__increment_value()
|
||||
|
||||
def button_release(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
|
||||
event.window.set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
|
||||
|
||||
self.__active_increment = False
|
||||
self.__pointer_position = 0
|
||||
@@ -291,67 +281,66 @@ class ControlVariableWidget(gtk.DrawingArea):
|
||||
|
||||
self.queue_draw()
|
||||
|
||||
def expose(self, widget, event):
|
||||
def draw(self, widget, context):
|
||||
"""
|
||||
Drawing callback
|
||||
@type widget: GtkWidget
|
||||
@param widget: Gtk widget superclass
|
||||
@type event: GtkEvent
|
||||
@param event: Gtk event of widget
|
||||
@type context: cairo.Context
|
||||
@param context: cairo context class
|
||||
@rtype: boolean
|
||||
@return: Indicator of the event propagation
|
||||
"""
|
||||
self.set_size_request(100, 30)
|
||||
|
||||
self.context = widget.window.cairo_create()
|
||||
self.__draw()
|
||||
self.__draw(context)
|
||||
|
||||
return True
|
||||
|
||||
def __draw(self):
|
||||
def __draw(self, context):
|
||||
"""
|
||||
"""
|
||||
allocation = self.get_allocation()
|
||||
|
||||
self.__center_of_widget = (allocation.width / 2,
|
||||
allocation.height / 2)
|
||||
self.__center_of_widget = (allocation.width // 2,
|
||||
allocation.height // 2)
|
||||
|
||||
xc, yc = self.__center_of_widget
|
||||
|
||||
# draw line
|
||||
self.context.set_line_width(1)
|
||||
self.context.set_dash([1, 2])
|
||||
self.context.move_to(self.__radius,
|
||||
context.set_line_width(1)
|
||||
context.set_dash([1, 2])
|
||||
context.move_to(self.__radius,
|
||||
yc + self.__radius)
|
||||
self.context.line_to(2 * xc - 5,
|
||||
context.line_to(2 * xc - 5,
|
||||
yc + self.__radius)
|
||||
self.context.stroke()
|
||||
context.stroke()
|
||||
|
||||
# draw text
|
||||
self.context.set_dash([1, 0])
|
||||
self.context.set_font_size(10)
|
||||
context.set_dash([1, 0])
|
||||
context.set_font_size(10)
|
||||
|
||||
self.context.move_to(5, yc - self.__radius)
|
||||
self.context.show_text(self.__variable_name)
|
||||
context.move_to(5, yc - self.__radius)
|
||||
context.show_text(self.__variable_name)
|
||||
|
||||
width = self.context.text_extents(str(self.__value()))[2]
|
||||
self.context.move_to(2 * xc - width - 5, yc - self.__radius)
|
||||
self.context.show_text(str(self.__value()))
|
||||
width = context.text_extents(str(self.__value()))[2]
|
||||
context.move_to(2 * xc - width - 5, yc - self.__radius)
|
||||
context.show_text(str(self.__value()))
|
||||
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
# draw node
|
||||
self.context.arc(xc + self.__pointer_position,
|
||||
context.arc(xc + self.__pointer_position,
|
||||
yc + self.__radius,
|
||||
self.__radius, 0, 2 * math.pi)
|
||||
if self.__active_increment:
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
else:
|
||||
self.context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
self.context.fill_preserve()
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
self.context.stroke()
|
||||
context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
context.fill_preserve()
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.stroke()
|
||||
|
||||
def __button_is_clicked(self, pointer):
|
||||
"""
|
||||
@@ -370,7 +359,7 @@ class ControlVariableWidget(gtk.DrawingArea):
|
||||
|
||||
if self.__active_increment:
|
||||
|
||||
gobject.timeout_add(self.__increment_time,
|
||||
GLib.timeout_add(self.__increment_time,
|
||||
self.__increment_value)
|
||||
|
||||
def set_value_function(self, value):
|
||||
@@ -410,18 +399,20 @@ class ControlVariable(BWHBox):
|
||||
self.__set_function,
|
||||
self.__increment_pass)
|
||||
|
||||
self.__left_button = gtk.Button()
|
||||
self.__left_button = Gtk.Button()
|
||||
self.__left_button.set_size_request(20, 20)
|
||||
self.__left_arrow = gtk.Arrow(gtk.ARROW_LEFT, gtk.SHADOW_NONE)
|
||||
self.__left_arrow = Gtk.Image.new_from_icon_name("pan-start-symbolic",
|
||||
Gtk.IconSize.BUTTON);
|
||||
self.__left_button.add(self.__left_arrow)
|
||||
self.__left_button.connect('pressed',
|
||||
self.__pressed,
|
||||
-self.__increment_pass)
|
||||
self.__left_button.connect('released', self.__released)
|
||||
|
||||
self.__right_button = gtk.Button()
|
||||
self.__right_button = Gtk.Button()
|
||||
self.__right_button.set_size_request(20, 20)
|
||||
self.__right_arrow = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE)
|
||||
self.__right_arrow = Gtk.Image.new_from_icon_name("pan-end-symbolic",
|
||||
Gtk.IconSize.BUTTON);
|
||||
self.__right_button.add(self.__right_arrow)
|
||||
self.__right_button.connect('pressed',
|
||||
self.__pressed,
|
||||
@@ -446,7 +437,7 @@ class ControlVariable(BWHBox):
|
||||
self.__set_function(self.__get_function() + increment)
|
||||
self.__control.verify_value()
|
||||
|
||||
gobject.timeout_add(self.__increment_time,
|
||||
GLib.timeout_add(self.__increment_time,
|
||||
self.__increment_function,
|
||||
increment)
|
||||
|
||||
@@ -475,29 +466,28 @@ class ControlFisheye(BWVBox):
|
||||
"""
|
||||
self.__params = BWHBox()
|
||||
|
||||
self.__fisheye_label = gtk.Label(_('<b>Fisheye</b> on ring'))
|
||||
self.__fisheye_label = Gtk.Label.new(_('<b>Fisheye</b> on ring'))
|
||||
self.__fisheye_label.set_use_markup(True)
|
||||
|
||||
self.__ring = gtk.Adjustment(0, 0, self.__ring_max_value, 0.01, 0.01)
|
||||
self.__ring = Gtk.Adjustment.new(0, 0, self.__ring_max_value, 0.01, 0.01, 0)
|
||||
|
||||
self.__ring_spin = gtk.SpinButton(self.__ring)
|
||||
self.__ring_spin = Gtk.SpinButton(adjustment=self.__ring)
|
||||
self.__ring_spin.set_digits(2)
|
||||
|
||||
self.__ring_scale = gtk.HScale(self.__ring)
|
||||
self.__ring_scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=self.__ring)
|
||||
self.__ring_scale.set_size_request(100, -1)
|
||||
self.__ring_scale.set_digits(2)
|
||||
self.__ring_scale.set_value_pos(gtk.POS_LEFT)
|
||||
self.__ring_scale.set_value_pos(Gtk.PositionType.LEFT)
|
||||
self.__ring_scale.set_draw_value(False)
|
||||
self.__ring_scale.set_update_policy(gtk.UPDATE_CONTINUOUS)
|
||||
|
||||
self.__interest_label = gtk.Label(_('with interest factor'))
|
||||
self.__interest = gtk.Adjustment(0, 0, 10, 0.01)
|
||||
self.__interest_spin = gtk.SpinButton(self.__interest)
|
||||
self.__interest_label = Gtk.Label.new(_('with interest factor'))
|
||||
self.__interest = Gtk.Adjustment.new(0, 0, 10, 0.01, 0, 0)
|
||||
self.__interest_spin = Gtk.SpinButton(adjustment=self.__interest)
|
||||
self.__interest_spin.set_digits(2)
|
||||
|
||||
self.__spread_label = gtk.Label(_('and spread factor'))
|
||||
self.__spread = gtk.Adjustment(0, -1.0, 1.0, 0.01, 0.01)
|
||||
self.__spread_spin = gtk.SpinButton(self.__spread)
|
||||
self.__spread_label = Gtk.Label.new(_('and spread factor'))
|
||||
self.__spread = Gtk.Adjustment.new(0, -1.0, 1.0, 0.01, 0.01, 0)
|
||||
self.__spread_spin = Gtk.SpinButton(adjustment=self.__spread)
|
||||
self.__spread_spin.set_digits(2)
|
||||
|
||||
self.__params.bw_pack_start_noexpand_nofill(self.__fisheye_label)
|
||||
@@ -514,7 +504,7 @@ class ControlFisheye(BWVBox):
|
||||
self.__interest.connect('value_changed', self.__change_interest)
|
||||
self.__spread.connect('value_changed', self.__change_spread)
|
||||
|
||||
gobject.timeout_add(REFRESH_RATE, self.__update_fisheye)
|
||||
GLib.timeout_add(REFRESH_RATE, self.__update_fisheye)
|
||||
|
||||
def __update_fisheye(self):
|
||||
"""
|
||||
@@ -532,7 +522,7 @@ class ControlFisheye(BWVBox):
|
||||
elif value > ring_max_value:
|
||||
value = ring_max_value
|
||||
|
||||
self.__ring.set_all(value, 1, ring_max_value, 0.01, 0.01, 0)
|
||||
self.__ring.configure(value, 1, ring_max_value, 0.01, 0.01, 0)
|
||||
self.__ring_max_value = ring_max_value
|
||||
|
||||
self.__ring_scale.queue_draw()
|
||||
@@ -611,9 +601,10 @@ class ControlInterpolation(BWExpander):
|
||||
"""
|
||||
self.__vbox = BWVBox()
|
||||
|
||||
self.__cartesian_radio = gtk.RadioButton(None, _('Cartesian'))
|
||||
self.__polar_radio = gtk.RadioButton(
|
||||
self.__cartesian_radio, _('Polar'))
|
||||
self.__cartesian_radio = Gtk.RadioButton(group=None,
|
||||
label=_('Cartesian'))
|
||||
self.__polar_radio = Gtk.RadioButton(group=self.__cartesian_radio,
|
||||
label=_('Polar'))
|
||||
self.__cartesian_radio.connect('toggled',
|
||||
self.__change_system,
|
||||
RadialNet.INTERPOLATION_CARTESIAN)
|
||||
@@ -626,14 +617,12 @@ class ControlInterpolation(BWExpander):
|
||||
self.__system_box.bw_pack_start_noexpand_nofill(self.__cartesian_radio)
|
||||
|
||||
self.__frames_box = BWHBox()
|
||||
self.__frames_label = gtk.Label(_('Frames'))
|
||||
self.__frames_label = Gtk.Label.new(_('Frames'))
|
||||
self.__frames_label.set_alignment(0.0, 0.5)
|
||||
self.__frames = gtk.Adjustment(self.radialnet.get_number_of_frames(),
|
||||
1,
|
||||
1000,
|
||||
1)
|
||||
self.__frames = Gtk.Adjustment.new(
|
||||
self.radialnet.get_number_of_frames(), 1, 1000, 1, 0, 0)
|
||||
self.__frames.connect('value_changed', self.__change_frames)
|
||||
self.__frames_spin = gtk.SpinButton(self.__frames)
|
||||
self.__frames_spin = Gtk.SpinButton(adjustment=self.__frames)
|
||||
self.__frames_box.bw_pack_start_expand_fill(self.__frames_label)
|
||||
self.__frames_box.bw_pack_start_noexpand_nofill(self.__frames_spin)
|
||||
|
||||
@@ -642,7 +631,7 @@ class ControlInterpolation(BWExpander):
|
||||
|
||||
self.bw_add(self.__vbox)
|
||||
|
||||
gobject.timeout_add(REFRESH_RATE, self.__update_animation)
|
||||
GLib.timeout_add(REFRESH_RATE, self.__update_animation)
|
||||
|
||||
def __update_animation(self):
|
||||
"""
|
||||
@@ -694,12 +683,12 @@ class ControlLayout(BWExpander):
|
||||
"""
|
||||
self.__hbox = BWHBox()
|
||||
|
||||
self.__layout = gtk.combo_box_new_text()
|
||||
self.__layout = Gtk.ComboBoxText()
|
||||
self.__layout.append_text(_('Symmetric'))
|
||||
self.__layout.append_text(_('Weighted'))
|
||||
self.__layout.set_active(self.radialnet.get_layout())
|
||||
self.__layout.connect('changed', self.__change_layout)
|
||||
self.__force = gtk.ToolButton(gtk.STOCK_REFRESH)
|
||||
self.__force = Gtk.ToolButton(Gtk.STOCK_REFRESH)
|
||||
self.__force.connect('clicked', self.__force_update)
|
||||
|
||||
self.__hbox.bw_pack_start_expand_fill(self.__layout)
|
||||
@@ -755,13 +744,11 @@ class ControlRingGap(BWVBox):
|
||||
self.radialnet.get_ring_gap,
|
||||
self.radialnet.set_ring_gap)
|
||||
|
||||
self.__label = gtk.Label(_('Lower ring gap'))
|
||||
self.__label = Gtk.Label.new(_('Lower ring gap'))
|
||||
self.__label.set_alignment(0.0, 0.5)
|
||||
self.__adjustment = gtk.Adjustment(self.radialnet.get_min_ring_gap(),
|
||||
0,
|
||||
50,
|
||||
1)
|
||||
self.__spin = gtk.SpinButton(self.__adjustment)
|
||||
self.__adjustment = Gtk.Adjustment.new(
|
||||
self.radialnet.get_min_ring_gap(), 0, 50, 1, 0, 0)
|
||||
self.__spin = Gtk.SpinButton(adjustment=self.__adjustment)
|
||||
self.__spin.connect('value_changed', self.__change_lower)
|
||||
|
||||
self.__lower_hbox = BWHBox()
|
||||
@@ -786,8 +773,8 @@ class ControlOptions(BWScrolledWindow):
|
||||
"""
|
||||
BWScrolledWindow.__init__(self)
|
||||
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
|
||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
|
||||
self.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
|
||||
self.radialnet = radialnet
|
||||
|
||||
@@ -798,8 +785,7 @@ class ControlOptions(BWScrolledWindow):
|
||||
def __create_widgets(self):
|
||||
"""
|
||||
"""
|
||||
self.__liststore = gtk.ListStore(gobject.TYPE_BOOLEAN,
|
||||
gobject.TYPE_STRING)
|
||||
self.__liststore = Gtk.ListStore.new([bool, str])
|
||||
|
||||
self.__liststore.append([None, OPTIONS[0]])
|
||||
self.__liststore.append([None, OPTIONS[1]])
|
||||
@@ -809,24 +795,24 @@ class ControlOptions(BWScrolledWindow):
|
||||
self.__liststore.append([None, OPTIONS[5]])
|
||||
self.__liststore.append([None, OPTIONS[6]])
|
||||
|
||||
self.__cell_toggle = gtk.CellRendererToggle()
|
||||
self.__cell_toggle = Gtk.CellRendererToggle()
|
||||
self.__cell_toggle.set_property('activatable', True)
|
||||
self.__cell_toggle.connect('toggled',
|
||||
self.__change_option,
|
||||
self.__liststore)
|
||||
|
||||
self.__column_toggle = gtk.TreeViewColumn('', self.__cell_toggle)
|
||||
self.__column_toggle = Gtk.TreeViewColumn(cell_renderer=self.__cell_toggle)
|
||||
self.__column_toggle.add_attribute(self.__cell_toggle, 'active', 0)
|
||||
self.__column_toggle.set_cell_data_func(self.__cell_toggle, self.__cell_toggle_data_method)
|
||||
|
||||
self.__cell_text = gtk.CellRendererText()
|
||||
self.__cell_text = Gtk.CellRendererText()
|
||||
|
||||
self.__column_text = gtk.TreeViewColumn(None,
|
||||
self.__cell_text,
|
||||
self.__column_text = Gtk.TreeViewColumn(title=None,
|
||||
cell_renderer=self.__cell_text,
|
||||
text=1)
|
||||
self.__column_text.set_cell_data_func(self.__cell_text, self.__cell_text_data_method)
|
||||
|
||||
self.__treeview = gtk.TreeView(self.__liststore)
|
||||
self.__treeview = Gtk.TreeView.new_with_model(self.__liststore)
|
||||
self.__treeview.set_enable_search(True)
|
||||
self.__treeview.set_search_column(1)
|
||||
self.__treeview.set_headers_visible(False)
|
||||
@@ -835,15 +821,15 @@ class ControlOptions(BWScrolledWindow):
|
||||
|
||||
self.add_with_viewport(self.__treeview)
|
||||
|
||||
gobject.timeout_add(REFRESH_RATE, self.__update_options)
|
||||
GObject.timeout_add(REFRESH_RATE, self.__update_options)
|
||||
|
||||
def __cell_toggle_data_method(self, column, cell, model, it):
|
||||
def __cell_toggle_data_method(self, column, cell, model, it, data):
|
||||
if not self.enable_labels and model.get_value(it, 1) == 'hostname':
|
||||
cell.set_property('activatable', False)
|
||||
else:
|
||||
cell.set_property('activatable', True)
|
||||
|
||||
def __cell_text_data_method(self, column, cell, model, it):
|
||||
def __cell_text_data_method(self, column, cell, model, it, data):
|
||||
if not self.enable_labels and model.get_value(it, 1) == 'hostname':
|
||||
cell.set_property('strikethrough', True)
|
||||
else:
|
||||
@@ -935,13 +921,13 @@ class ControlView(BWExpander):
|
||||
self.bw_add(self.__vbox)
|
||||
|
||||
|
||||
class ControlNavigation(gtk.DrawingArea):
|
||||
class ControlNavigation(Gtk.DrawingArea):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, radialnet):
|
||||
"""
|
||||
"""
|
||||
gtk.DrawingArea.__init__(self)
|
||||
Gtk.DrawingArea.__init__(self)
|
||||
|
||||
self.radialnet = radialnet
|
||||
|
||||
@@ -972,7 +958,7 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
self.__rotate_clicked = False
|
||||
self.__move_clicked = None
|
||||
|
||||
self.connect('expose_event', self.expose)
|
||||
self.connect('draw', self.draw)
|
||||
self.connect('button_press_event', self.button_press)
|
||||
self.connect('button_release_event', self.button_release)
|
||||
self.connect('motion_notify_event', self.motion_notify)
|
||||
@@ -981,23 +967,21 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
self.connect('key_press_event', self.key_press)
|
||||
self.connect('key_release_event', self.key_release)
|
||||
|
||||
self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
|
||||
gtk.gdk.BUTTON_RELEASE_MASK |
|
||||
gtk.gdk.ENTER_NOTIFY |
|
||||
gtk.gdk.LEAVE_NOTIFY |
|
||||
gtk.gdk.MOTION_NOTIFY |
|
||||
gtk.gdk.NOTHING |
|
||||
gtk.gdk.KEY_PRESS_MASK |
|
||||
gtk.gdk.KEY_RELEASE_MASK |
|
||||
gtk.gdk.POINTER_MOTION_HINT_MASK |
|
||||
gtk.gdk.POINTER_MOTION_MASK)
|
||||
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
|
||||
Gdk.EventMask.BUTTON_RELEASE_MASK |
|
||||
Gdk.EventMask.ENTER_NOTIFY_MASK |
|
||||
Gdk.EventMask.LEAVE_NOTIFY_MASK |
|
||||
Gdk.EventMask.KEY_PRESS_MASK |
|
||||
Gdk.EventMask.KEY_RELEASE_MASK |
|
||||
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||
Gdk.EventMask.POINTER_MOTION_MASK)
|
||||
|
||||
self.__rotate_node.set_coordinate(40, self.radialnet.get_rotation())
|
||||
|
||||
def key_press(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
# key = gtk.gdk.keyval_name(event.keyval)
|
||||
# key = Gdk.keyval_name(event.keyval)
|
||||
|
||||
self.queue_draw()
|
||||
|
||||
@@ -1006,7 +990,7 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
def key_release(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
# key = gtk.gdk.keyval_name(event.keyval)
|
||||
# key = Gdk.keyval_name(event.keyval)
|
||||
|
||||
self.queue_draw()
|
||||
|
||||
@@ -1040,20 +1024,20 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
|
||||
if self.__rotate_is_clicked(pointer):
|
||||
|
||||
event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
|
||||
event.window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2))
|
||||
self.__rotating = True
|
||||
|
||||
direction = self.__move_is_clicked(pointer)
|
||||
|
||||
if direction is not None and self.__moving is None:
|
||||
|
||||
event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
|
||||
event.window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2))
|
||||
self.__moving = direction
|
||||
self.__move_in_direction(direction)
|
||||
|
||||
if self.__center_is_clicked(pointer):
|
||||
|
||||
event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
|
||||
event.window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2))
|
||||
self.__centering = True
|
||||
self.__move_position = (0, 0)
|
||||
self.radialnet.set_translation(self.__move_position)
|
||||
@@ -1077,7 +1061,7 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
self.__rotating = False # stop rotate
|
||||
self.__move_factor = 1
|
||||
|
||||
event.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
|
||||
event.window.set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
|
||||
|
||||
self.queue_draw()
|
||||
|
||||
@@ -1114,24 +1098,23 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
|
||||
return False
|
||||
|
||||
def expose(self, widget, event):
|
||||
def draw(self, widget, context):
|
||||
"""
|
||||
Drawing callback
|
||||
@type widget: GtkWidget
|
||||
@param widget: Gtk widget superclass
|
||||
@type event: GtkEvent
|
||||
@param event: Gtk event of widget
|
||||
@type context: cairo.Context
|
||||
@param context: cairo context class
|
||||
@rtype: boolean
|
||||
@return: Indicator of the event propagation
|
||||
"""
|
||||
self.set_size_request(120, 130)
|
||||
|
||||
self.context = widget.window.cairo_create()
|
||||
self.__draw()
|
||||
self.__draw(context)
|
||||
|
||||
return False
|
||||
|
||||
def __draw_rotate_control(self):
|
||||
def __draw_rotate_control(self, context):
|
||||
"""
|
||||
"""
|
||||
xc, yc = self.__center_of_widget
|
||||
@@ -1139,100 +1122,99 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
x, y = self.__rotate_node.to_cartesian()
|
||||
|
||||
# draw text
|
||||
self.context.set_font_size(10)
|
||||
self.context.move_to(xc - 49, yc - 48)
|
||||
self.context.show_text(_("Navigation"))
|
||||
context.set_font_size(10)
|
||||
context.move_to(xc - 49, yc - 48)
|
||||
context.show_text(_("Navigation"))
|
||||
|
||||
width = self.context.text_extents(str(int(t)))[2]
|
||||
self.context.move_to(xc + 49 - width - 2, yc - 48)
|
||||
self.context.show_text(str(round(t, 1)))
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
width = context.text_extents(str(int(t)))[2]
|
||||
context.move_to(xc + 49 - width - 2, yc - 48)
|
||||
context.show_text(str(round(t, 1)))
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
# draw arc
|
||||
self.context.set_dash([1, 2])
|
||||
self.context.arc(xc, yc, 40, 0, 2 * math.pi)
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
context.set_dash([1, 2])
|
||||
context.arc(xc, yc, 40, 0, 2 * math.pi)
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
# draw node
|
||||
self.context.set_dash([1, 0])
|
||||
self.context.arc(xc + x, yc - y, self.__rotate_radius, 0, 2 * math.pi)
|
||||
context.set_dash([1, 0])
|
||||
context.arc(xc + x, yc - y, self.__rotate_radius, 0, 2 * math.pi)
|
||||
|
||||
if self.__rotating:
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
else:
|
||||
self.context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
|
||||
self.context.fill_preserve()
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
context.fill_preserve()
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
return False
|
||||
|
||||
def __draw_move_control(self):
|
||||
def __draw_move_control(self, context):
|
||||
"""
|
||||
"""
|
||||
xc, yc = self.__center_of_widget
|
||||
pc = PolarCoordinate()
|
||||
|
||||
self.context.set_dash([1, 1])
|
||||
self.context.arc(xc, yc, 23, 0, 2 * math.pi)
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
context.set_dash([1, 1])
|
||||
context.arc(xc, yc, 23, 0, 2 * math.pi)
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
for i in range(8):
|
||||
|
||||
pc.set_coordinate(23, 45 * i)
|
||||
x, y = pc.to_cartesian()
|
||||
|
||||
self.context.set_dash([1, 1])
|
||||
self.context.move_to(xc, yc)
|
||||
self.context.line_to(xc + x, yc - y)
|
||||
self.context.stroke()
|
||||
context.set_dash([1, 1])
|
||||
context.move_to(xc, yc)
|
||||
context.line_to(xc + x, yc - y)
|
||||
context.stroke()
|
||||
|
||||
self.context.set_dash([1, 0])
|
||||
self.context.arc(
|
||||
context.set_dash([1, 0])
|
||||
context.arc(
|
||||
xc + x, yc - y, self.__move_radius, 0, 2 * math.pi)
|
||||
|
||||
if i == self.__moving:
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
else:
|
||||
self.context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
self.context.fill_preserve()
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
context.fill_preserve()
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
self.context.arc(xc, yc, 6, 0, 2 * math.pi)
|
||||
context.arc(xc, yc, 6, 0, 2 * math.pi)
|
||||
|
||||
if self.__centering:
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
else:
|
||||
self.context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
self.context.fill_preserve()
|
||||
self.context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
self.context.set_line_width(1)
|
||||
self.context.stroke()
|
||||
context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
context.fill_preserve()
|
||||
context.set_source_rgb(0.0, 0.0, 0.0)
|
||||
context.set_line_width(1)
|
||||
context.stroke()
|
||||
|
||||
return False
|
||||
|
||||
def __draw(self):
|
||||
def __draw(self, context):
|
||||
"""
|
||||
Drawing method
|
||||
"""
|
||||
# Getting allocation reference
|
||||
allocation = self.get_allocation()
|
||||
|
||||
self.__center_of_widget = (allocation.width / 2,
|
||||
allocation.height / 2)
|
||||
self.__center_of_widget = (allocation.width // 2,
|
||||
allocation.height // 2)
|
||||
|
||||
self.__draw_rotate_control()
|
||||
self.__draw_move_control()
|
||||
self.__draw_rotate_control(context)
|
||||
self.__draw_move_control(context)
|
||||
|
||||
return False
|
||||
|
||||
@@ -1251,7 +1233,7 @@ class ControlNavigation(gtk.DrawingArea):
|
||||
if self.__move_factor < self.__move_factor_limit:
|
||||
self.__move_factor += 1
|
||||
|
||||
gobject.timeout_add(self.__move_pass,
|
||||
GObject.timeout_add(self.__move_pass,
|
||||
self.__move_in_direction,
|
||||
direction)
|
||||
|
||||
|
||||
@@ -57,19 +57,22 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from radialnet.core.Info import INFO
|
||||
from radialnet.gui.Image import Pixmaps
|
||||
|
||||
|
||||
class AboutDialog(gtk.AboutDialog):
|
||||
class AboutDialog(Gtk.AboutDialog):
|
||||
"""
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
"""
|
||||
gtk.AboutDialog.__init__(self)
|
||||
Gtk.AboutDialog.__init__(self)
|
||||
|
||||
self.set_name(INFO['name'])
|
||||
self.set_version(INFO['version'])
|
||||
|
||||
@@ -57,9 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import re
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
from radialnet.bestwidgets.windows import BWMainWindow
|
||||
|
||||
@@ -73,7 +76,7 @@ HOSTS_HEADER = ['ID', '#', 'Hosts']
|
||||
|
||||
DIMENSION = (700, 400)
|
||||
|
||||
IP_RE = re.compile('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$')
|
||||
IP_RE = re.compile(r'^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$')
|
||||
|
||||
|
||||
class HostsViewer(BWMainWindow):
|
||||
@@ -87,7 +90,7 @@ class HostsViewer(BWMainWindow):
|
||||
self.set_default_size(DIMENSION[0], DIMENSION[1])
|
||||
|
||||
self.__nodes = nodes
|
||||
self.__default_view = gtk.Label(_("No node selected"))
|
||||
self.__default_view = Gtk.Label.new(_("No node selected"))
|
||||
self.__view = self.__default_view
|
||||
|
||||
self.__create_widgets()
|
||||
@@ -95,7 +98,7 @@ class HostsViewer(BWMainWindow):
|
||||
def __create_widgets(self):
|
||||
"""
|
||||
"""
|
||||
self.__panel = gtk.HPaned()
|
||||
self.__panel = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
|
||||
self.__panel.set_border_width(6)
|
||||
|
||||
self.__list = HostsList(self, self.__nodes)
|
||||
@@ -121,15 +124,15 @@ class HostsViewer(BWMainWindow):
|
||||
self.__panel.add2(self.__view)
|
||||
|
||||
|
||||
class HostsList(gtk.ScrolledWindow):
|
||||
class HostsList(Gtk.ScrolledWindow):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, parent, nodes):
|
||||
"""
|
||||
"""
|
||||
super(HostsList, self).__init__()
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
|
||||
self.__parent = parent
|
||||
self.__nodes = nodes
|
||||
@@ -139,15 +142,11 @@ class HostsList(gtk.ScrolledWindow):
|
||||
def __create_widgets(self):
|
||||
"""
|
||||
"""
|
||||
self.__cell = gtk.CellRendererText()
|
||||
self.__cell = Gtk.CellRendererText()
|
||||
|
||||
self.__hosts_store = gtk.ListStore(gobject.TYPE_INT,
|
||||
gobject.TYPE_INT,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
self.__hosts_store = Gtk.ListStore.new([int, int, str, str, bool])
|
||||
|
||||
self.__hosts_treeview = gtk.TreeView(self.__hosts_store)
|
||||
self.__hosts_treeview = Gtk.TreeView.new_with_model(self.__hosts_store)
|
||||
self.__hosts_treeview.connect('cursor-changed', self.__cursor_callback)
|
||||
|
||||
for i in range(len(self.__nodes)):
|
||||
@@ -169,8 +168,8 @@ class HostsList(gtk.ScrolledWindow):
|
||||
|
||||
for i in range(0, len(HOSTS_HEADER)):
|
||||
|
||||
column = gtk.TreeViewColumn(HOSTS_HEADER[i],
|
||||
self.__cell,
|
||||
column = Gtk.TreeViewColumn(title=HOSTS_HEADER[i],
|
||||
cell_renderer=self.__cell,
|
||||
text=i)
|
||||
|
||||
self.__hosts_column.append(column)
|
||||
@@ -207,7 +206,7 @@ class HostsList(gtk.ScrolledWindow):
|
||||
|
||||
self.__parent.change_notebook(node)
|
||||
|
||||
def __host_sort(self, treemodel, iter1, iter2):
|
||||
def __host_sort(self, treemodel, iter1, iter2, *_):
|
||||
"""
|
||||
"""
|
||||
value1 = treemodel.get_value(iter1, 2)
|
||||
|
||||
@@ -57,8 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GdkPixbuf
|
||||
|
||||
import os
|
||||
import gtk
|
||||
import array
|
||||
|
||||
from zenmapCore.Paths import Path
|
||||
@@ -74,8 +78,8 @@ def get_pixels_for_cairo_image_surface(pixbuf):
|
||||
containing the icon pixels of a gtk.gdk.Pixbuf that can be used by
|
||||
cairo.ImageSurface.create_for_data() method.
|
||||
"""
|
||||
data = array.ArrayType('c')
|
||||
format = pixbuf.get_rowstride() / pixbuf.get_width()
|
||||
data = array.array('B')
|
||||
image_format = pixbuf.get_rowstride() // pixbuf.get_width()
|
||||
|
||||
i = 0
|
||||
j = 0
|
||||
@@ -83,16 +87,16 @@ def get_pixels_for_cairo_image_surface(pixbuf):
|
||||
|
||||
b, g, r = pixbuf.get_pixels()[i:i + FORMAT_RGB]
|
||||
|
||||
if format == FORMAT_RGBA:
|
||||
if image_format == FORMAT_RGBA:
|
||||
a = pixbuf.get_pixels()[i + FORMAT_RGBA - 1]
|
||||
elif format == FORMAT_RGB:
|
||||
a = '\xff'
|
||||
elif image_format == FORMAT_RGB:
|
||||
a = 255
|
||||
else:
|
||||
raise TypeError('unknown image format')
|
||||
|
||||
data[j:j + FORMAT_RGBA] = array.ArrayType('c', [r, g, b, a])
|
||||
data[j:j + FORMAT_RGBA] = array.array('B', [r, g, b, a])
|
||||
|
||||
i += format
|
||||
i += image_format
|
||||
j += FORMAT_RGBA
|
||||
|
||||
return (FORMAT_RGBA * pixbuf.get_width(), data)
|
||||
@@ -122,7 +126,7 @@ class Image:
|
||||
|
||||
file = self.get_icon(icon, image_type)
|
||||
self.__cache[icon + image_type] = \
|
||||
gtk.gdk.pixbuf_new_from_file(file)
|
||||
GdkPixbuf.Pixbuf.new_from_file(file)
|
||||
|
||||
return self.__cache[icon + image_type]
|
||||
|
||||
|
||||
@@ -57,8 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, Pango
|
||||
|
||||
import math
|
||||
import cairo
|
||||
|
||||
@@ -69,7 +72,9 @@ DIMENSION_NORMAL = (350, 450)
|
||||
|
||||
|
||||
def draw_pixmap(context, x, y, name, label):
|
||||
context.set_source_pixbuf(Pixmaps().get_pixbuf(name), x, y)
|
||||
# This is pretty hideous workaround
|
||||
Gdk.cairo_set_source_pixbuf(context, Pixmaps().get_pixbuf(name), x, y)
|
||||
#context.set_source_pixbuf()
|
||||
context.paint()
|
||||
context.move_to(x + 50, y + 10)
|
||||
context.set_source_rgb(0, 0, 0)
|
||||
@@ -124,117 +129,116 @@ def draw_line(context, x, y, dash, color, label):
|
||||
context.show_text(label)
|
||||
|
||||
|
||||
class LegendWindow(gtk.Window):
|
||||
class LegendWindow(Gtk.Window):
|
||||
"""
|
||||
"""
|
||||
def __init__(self):
|
||||
"""
|
||||
"""
|
||||
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
|
||||
Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL)
|
||||
self.set_default_size(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
|
||||
self.__title_font = pango.FontDescription("Monospace Bold")
|
||||
self.__title_font = Pango.FontDescription("Monospace Bold")
|
||||
self.set_title(_("Topology Legend"))
|
||||
|
||||
self.vbox = gtk.VBox()
|
||||
self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
self.add(self.vbox)
|
||||
|
||||
self.drawing_area = gtk.DrawingArea()
|
||||
self.vbox.pack_start(self.drawing_area)
|
||||
self.drawing_area.connect("expose-event", self.expose_event_handler)
|
||||
self.more_uri = gtk.LinkButton(
|
||||
self.drawing_area = Gtk.DrawingArea()
|
||||
self.vbox.pack_start(self.drawing_area, True, True, 0)
|
||||
self.drawing_area.connect("draw", self.draw_event_handler)
|
||||
self.more_uri = Gtk.LinkButton.new_with_label(
|
||||
"https://nmap.org/book/zenmap-topology.html#zenmap-topology-legend",
|
||||
label=_("View full legend online"))
|
||||
self.vbox.pack_start(self.more_uri, False, False)
|
||||
_("View full legend online"))
|
||||
self.vbox.pack_start(self.more_uri, False, False, 0)
|
||||
|
||||
def expose_event_handler(self, widget, event):
|
||||
def draw_event_handler(self, widget, graphic_context):
|
||||
"""
|
||||
"""
|
||||
self.graphic_context = widget.window.cairo_create()
|
||||
x, y = 45, 20
|
||||
draw_heading(self.graphic_context, x, y, _("Hosts"))
|
||||
draw_heading(graphic_context, x, y, _("Hosts"))
|
||||
|
||||
# white circle
|
||||
y += 20
|
||||
draw_circle(self.graphic_context, x, y, 3, (1, 1, 1),
|
||||
draw_circle(graphic_context, x, y, 3, (1, 1, 1),
|
||||
_("host was not port scanned"))
|
||||
# green circle
|
||||
y += 20
|
||||
draw_circle(self.graphic_context, x, y, 4, (0, 1, 0),
|
||||
draw_circle(graphic_context, x, y, 4, (0, 1, 0),
|
||||
_("host with fewer than 3 open ports"))
|
||||
# yellow circle
|
||||
y += 20
|
||||
draw_circle(self.graphic_context, x, y, 5, (1, 1, 0),
|
||||
draw_circle(graphic_context, x, y, 5, (1, 1, 0),
|
||||
_("host with 3 to 6 open ports"))
|
||||
# red circle
|
||||
y += 20
|
||||
draw_circle(self.graphic_context, x, y, 6, (1, 0, 0),
|
||||
draw_circle(graphic_context, x, y, 6, (1, 0, 0),
|
||||
_("host with more than 6 open ports"))
|
||||
|
||||
# green square
|
||||
y += 20
|
||||
rx = x - 20
|
||||
draw_square(self.graphic_context, rx, y, 10, (0, 1, 0))
|
||||
draw_square(graphic_context, rx, y, 10, (0, 1, 0))
|
||||
rx += 10 + 5
|
||||
# yellow square
|
||||
draw_square(self.graphic_context, rx, y, 12, (1, 1, 0))
|
||||
draw_square(graphic_context, rx, y, 12, (1, 1, 0))
|
||||
rx += 12 + 5
|
||||
# red square
|
||||
draw_square(self.graphic_context, rx, y, 14, (1, 0, 0))
|
||||
draw_square(graphic_context, rx, y, 14, (1, 0, 0))
|
||||
|
||||
self.graphic_context.move_to(x + 50, y + 5)
|
||||
self.graphic_context.set_source_rgb(0, 0, 0)
|
||||
self.graphic_context.show_text(_("host is a router, switch, or WAP"))
|
||||
graphic_context.move_to(x + 50, y + 5)
|
||||
graphic_context.set_source_rgb(0, 0, 0)
|
||||
graphic_context.show_text(_("host is a router, switch, or WAP"))
|
||||
|
||||
# connections between hosts
|
||||
y += 30
|
||||
draw_heading(self.graphic_context, x, y, _("Traceroute connections"))
|
||||
draw_heading(graphic_context, x, y, _("Traceroute connections"))
|
||||
|
||||
y += 20
|
||||
self.graphic_context.move_to(x, y)
|
||||
self.graphic_context.show_text(_("Thicker line means higher round-trip time"))
|
||||
graphic_context.move_to(x, y)
|
||||
graphic_context.show_text(_("Thicker line means higher round-trip time"))
|
||||
# primary traceroute (blue line)
|
||||
y += 20
|
||||
draw_line(self.graphic_context, x, y, [], (0, 0, 1),
|
||||
draw_line(graphic_context, x, y, [], (0, 0, 1),
|
||||
_("primary traceroute connection"))
|
||||
# Alternate route (orange line)
|
||||
y += 20
|
||||
draw_line(self.graphic_context, x, y, [], (1, 0.5, 0),
|
||||
draw_line(graphic_context, x, y, [], (1, 0.5, 0),
|
||||
_("alternate path"))
|
||||
# no traceroute
|
||||
y += 20
|
||||
draw_line(self.graphic_context, x, y, [4.0, 2.0], (0, 0, 0),
|
||||
draw_line(graphic_context, x, y, [4.0, 2.0], (0, 0, 0),
|
||||
_("no traceroute information"))
|
||||
# missing traceroute
|
||||
y += 20
|
||||
self.graphic_context.set_source_rgb(0.5, 0.7, 0.95)
|
||||
self.graphic_context.move_to(x - 15, y)
|
||||
self.graphic_context.arc(x - 25, y, 5, 0, 2 * math.pi)
|
||||
self.graphic_context.stroke_preserve()
|
||||
draw_line(self.graphic_context, x, y, [4.0, 2.0], (0.5, 0.7, 0.95),
|
||||
graphic_context.set_source_rgb(0.5, 0.7, 0.95)
|
||||
graphic_context.move_to(x - 15, y)
|
||||
graphic_context.arc(x - 25, y, 5, 0, 2 * math.pi)
|
||||
graphic_context.stroke_preserve()
|
||||
draw_line(graphic_context, x, y, [4.0, 2.0], (0.5, 0.7, 0.95),
|
||||
_("missing traceroute hop"))
|
||||
|
||||
# special purpose hosts
|
||||
y += 30
|
||||
draw_heading(self.graphic_context, x, y, _("Additional host icons"))
|
||||
draw_heading(graphic_context, x, y, _("Additional host icons"))
|
||||
|
||||
# router image
|
||||
y += 20
|
||||
draw_pixmap(self.graphic_context, x, y, "router", _("router"))
|
||||
draw_pixmap(graphic_context, x, y, "router", _("router"))
|
||||
|
||||
# switch image
|
||||
y += 20
|
||||
draw_pixmap(self.graphic_context, x, y, "switch", _("switch"))
|
||||
draw_pixmap(graphic_context, x, y, "switch", _("switch"))
|
||||
|
||||
# wap image
|
||||
y += 20
|
||||
draw_pixmap(self.graphic_context, x, y, "wireless",
|
||||
draw_pixmap(graphic_context, x, y, "wireless",
|
||||
_("wireless access point"))
|
||||
|
||||
# firewall image
|
||||
y += 20
|
||||
draw_pixmap(self.graphic_context, x, y, "firewall", _("firewall"))
|
||||
draw_pixmap(graphic_context, x, y, "firewall", _("firewall"))
|
||||
|
||||
# host with filtered ports
|
||||
y += 20
|
||||
draw_pixmap(self.graphic_context, x, y, "padlock",
|
||||
draw_pixmap(graphic_context, x, y, "padlock",
|
||||
_("host with some filtered ports"))
|
||||
|
||||
@@ -57,9 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject, Pango
|
||||
|
||||
from radialnet.bestwidgets.boxes import BWVBox, BWHBox, BWScrolledWindow, BWTable
|
||||
from radialnet.bestwidgets.expanders import BWExpander
|
||||
@@ -109,14 +110,14 @@ def get_service_color(state):
|
||||
return color
|
||||
|
||||
|
||||
class NodeNotebook(gtk.Notebook):
|
||||
class NodeNotebook(Gtk.Notebook):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, node):
|
||||
"""
|
||||
"""
|
||||
gtk.Notebook.__init__(self)
|
||||
self.set_tab_pos(gtk.POS_TOP)
|
||||
Gtk.Notebook.__init__(self)
|
||||
self.set_tab_pos(Gtk.PositionType.TOP)
|
||||
|
||||
self.__node = node
|
||||
|
||||
@@ -136,25 +137,25 @@ class NodeNotebook(gtk.Notebook):
|
||||
self.append_page(self.__trace_page, BWLabel(_('Traceroute')))
|
||||
|
||||
|
||||
class ServicesPage(gtk.Notebook):
|
||||
class ServicesPage(Gtk.Notebook):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, node):
|
||||
"""
|
||||
"""
|
||||
gtk.Notebook.__init__(self)
|
||||
Gtk.Notebook.__init__(self)
|
||||
self.set_border_width(6)
|
||||
self.set_tab_pos(gtk.POS_TOP)
|
||||
self.set_tab_pos(Gtk.PositionType.TOP)
|
||||
|
||||
self.__node = node
|
||||
self.__font = pango.FontDescription('Monospace')
|
||||
self.__font = Pango.FontDescription('Monospace')
|
||||
|
||||
self.__create_widgets()
|
||||
|
||||
def __create_widgets(self):
|
||||
"""
|
||||
"""
|
||||
self.__cell = gtk.CellRendererText()
|
||||
self.__cell = Gtk.CellRendererText()
|
||||
|
||||
# texteditor widgets
|
||||
self.__texteditor = BWTextEditor()
|
||||
@@ -162,7 +163,7 @@ class ServicesPage(gtk.Notebook):
|
||||
self.__texteditor.bw_set_editable(False)
|
||||
self.__texteditor.set_border_width(0)
|
||||
|
||||
self.__select_combobox = gtk.combo_box_new_text()
|
||||
self.__select_combobox = Gtk.ComboBoxText()
|
||||
self.__select_combobox.connect('changed', self.__change_text_value)
|
||||
|
||||
self.__viewer = BWVBox(spacing=6)
|
||||
@@ -179,15 +180,15 @@ class ServicesPage(gtk.Notebook):
|
||||
|
||||
self.__ports_scroll = BWScrolledWindow()
|
||||
|
||||
self.__ports_store = gtk.TreeStore(gobject.TYPE_INT,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
self.__ports_store = Gtk.TreeStore.new([GObject.TYPE_INT,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_BOOLEAN])
|
||||
|
||||
self.__ports_treeview = gtk.TreeView(self.__ports_store)
|
||||
self.__ports_treeview = Gtk.TreeView.new_with_model(self.__ports_store)
|
||||
|
||||
for port in self.__node.get_info('ports'):
|
||||
|
||||
@@ -257,8 +258,8 @@ class ServicesPage(gtk.Notebook):
|
||||
|
||||
for i in range(len(PORTS_HEADER)):
|
||||
|
||||
column = gtk.TreeViewColumn(PORTS_HEADER[i],
|
||||
self.__cell,
|
||||
column = Gtk.TreeViewColumn(title=PORTS_HEADER[i],
|
||||
cell_renderer=self.__cell,
|
||||
text=i)
|
||||
|
||||
self.__ports_column.append(column)
|
||||
@@ -280,13 +281,13 @@ class ServicesPage(gtk.Notebook):
|
||||
|
||||
self.__xports_scroll = BWScrolledWindow()
|
||||
|
||||
self.__xports_store = gtk.TreeStore(gobject.TYPE_INT,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
self.__xports_store = Gtk.TreeStore.new([GObject.TYPE_INT,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_STRING,
|
||||
GObject.TYPE_BOOLEAN])
|
||||
|
||||
self.__xports_treeview = gtk.TreeView(self.__xports_store)
|
||||
self.__xports_treeview = Gtk.TreeView.new_with_model(self.__xports_store)
|
||||
|
||||
for xports in self.__node.get_info('extraports'):
|
||||
|
||||
@@ -309,8 +310,8 @@ class ServicesPage(gtk.Notebook):
|
||||
|
||||
for i in range(len(EXTRAPORTS_HEADER)):
|
||||
|
||||
column = gtk.TreeViewColumn(EXTRAPORTS_HEADER[i],
|
||||
self.__cell,
|
||||
column = Gtk.TreeViewColumn(title=EXTRAPORTS_HEADER[i],
|
||||
cell_renderer=self.__cell,
|
||||
text=i)
|
||||
|
||||
self.__xports_column.append(column)
|
||||
@@ -354,7 +355,7 @@ class SystemPage(BWScrolledWindow):
|
||||
BWScrolledWindow.__init__(self)
|
||||
|
||||
self.__node = node
|
||||
self.__font = pango.FontDescription('Monospace')
|
||||
self.__font = Pango.FontDescription('Monospace')
|
||||
|
||||
self.__create_widgets()
|
||||
|
||||
@@ -364,21 +365,21 @@ class SystemPage(BWScrolledWindow):
|
||||
self.__vbox = BWVBox()
|
||||
self.__vbox.set_border_width(6)
|
||||
|
||||
self.__cell = gtk.CellRendererText()
|
||||
self.__cell = Gtk.CellRendererText()
|
||||
|
||||
self.__general_frame = BWExpander(_('General information'))
|
||||
self.__sequences_frame = BWExpander(_('Sequences'))
|
||||
self.__os_frame = BWExpander(_('Operating System'))
|
||||
|
||||
self.__sequences_frame.bw_add(gtk.Label(_('No sequence information.')))
|
||||
self.__os_frame.bw_add(gtk.Label(_('No OS information.')))
|
||||
self.__sequences_frame.bw_add(Gtk.Label.new(_('No sequence information.')))
|
||||
self.__os_frame.bw_add(Gtk.Label.new(_('No OS information.')))
|
||||
|
||||
# general information widgets
|
||||
self.__general = BWTable(3, 2)
|
||||
|
||||
self.__address_label = BWSectionLabel(_('Address:'))
|
||||
self.__address_list = gtk.combo_box_entry_new_text()
|
||||
self.__address_list.child.set_editable(False)
|
||||
self.__address_list = Gtk.ComboBoxText.new_with_entry()
|
||||
self.__address_list.get_child().set_editable(False)
|
||||
|
||||
for address in self.__node.get_info('addresses'):
|
||||
|
||||
@@ -393,15 +394,15 @@ class SystemPage(BWScrolledWindow):
|
||||
self.__address_list.set_active(0)
|
||||
|
||||
self.__general.bw_attach_next(self.__address_label,
|
||||
yoptions=gtk.FILL,
|
||||
xoptions=gtk.FILL)
|
||||
self.__general.bw_attach_next(self.__address_list, yoptions=gtk.FILL)
|
||||
yoptions=Gtk.AttachOptions.FILL,
|
||||
xoptions=Gtk.AttachOptions.FILL)
|
||||
self.__general.bw_attach_next(self.__address_list, yoptions=Gtk.AttachOptions.FILL)
|
||||
|
||||
if self.__node.get_info('hostnames') is not None:
|
||||
|
||||
self.__hostname_label = BWSectionLabel(_('Hostname:'))
|
||||
self.__hostname_list = gtk.combo_box_entry_new_text()
|
||||
self.__hostname_list.child.set_editable(False)
|
||||
self.__hostname_list = Gtk.ComboBoxText.new_with_entry()
|
||||
self.__hostname_list.get_child().set_editable(False)
|
||||
|
||||
for hostname in self.__node.get_info('hostnames'):
|
||||
|
||||
@@ -411,10 +412,10 @@ class SystemPage(BWScrolledWindow):
|
||||
self.__hostname_list.set_active(0)
|
||||
|
||||
self.__general.bw_attach_next(self.__hostname_label,
|
||||
yoptions=gtk.FILL,
|
||||
xoptions=gtk.FILL)
|
||||
yoptions=Gtk.AttachOptions.FILL,
|
||||
xoptions=Gtk.AttachOptions.FILL)
|
||||
self.__general.bw_attach_next(self.__hostname_list,
|
||||
yoptions=gtk.FILL)
|
||||
yoptions=Gtk.AttachOptions.FILL)
|
||||
|
||||
if self.__node.get_info('uptime') is not None:
|
||||
|
||||
@@ -430,10 +431,10 @@ class SystemPage(BWScrolledWindow):
|
||||
self.__uptime_value.set_line_wrap(False)
|
||||
|
||||
self.__general.bw_attach_next(self.__uptime_label,
|
||||
yoptions=gtk.FILL,
|
||||
xoptions=gtk.FILL)
|
||||
yoptions=Gtk.AttachOptions.FILL,
|
||||
xoptions=Gtk.AttachOptions.FILL)
|
||||
self.__general.bw_attach_next(self.__uptime_value,
|
||||
yoptions=gtk.FILL)
|
||||
yoptions=Gtk.AttachOptions.FILL)
|
||||
|
||||
self.__general_frame.bw_add(self.__general)
|
||||
self.__general_frame.set_expanded(True)
|
||||
@@ -444,7 +445,7 @@ class SystemPage(BWScrolledWindow):
|
||||
self.__create_sequences_widget(sequences))
|
||||
|
||||
# operating system information widgets
|
||||
self.__os = gtk.Notebook()
|
||||
self.__os = Gtk.Notebook()
|
||||
|
||||
os = self.__node.get_info('os')
|
||||
|
||||
@@ -454,12 +455,8 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
self.__match_scroll = BWScrolledWindow()
|
||||
|
||||
self.__match_store = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_INT,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
|
||||
self.__match_treeview = gtk.TreeView(self.__match_store)
|
||||
self.__match_store = Gtk.ListStore.new([str, str, int, bool])
|
||||
self.__match_treeview = Gtk.TreeView.new_with_model(self.__match_store)
|
||||
|
||||
for os_match in os['matches']:
|
||||
|
||||
@@ -473,8 +470,8 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
for i in range(len(OSMATCH_HEADER)):
|
||||
|
||||
column = gtk.TreeViewColumn(OSMATCH_HEADER[i],
|
||||
self.__cell,
|
||||
column = Gtk.TreeViewColumn(title=OSMATCH_HEADER[i],
|
||||
cell_renderer=self.__cell,
|
||||
text=i)
|
||||
|
||||
self.__match_column.append(column)
|
||||
@@ -496,14 +493,8 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
self.__class_scroll = BWScrolledWindow()
|
||||
|
||||
self.__class_store = gtk.ListStore(gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
|
||||
self.__class_treeview = gtk.TreeView(self.__class_store)
|
||||
self.__class_store = Gtk.ListStore.new([str, str, str, str, str, bool])
|
||||
self.__class_treeview = Gtk.TreeView.new_with_model(self.__class_store)
|
||||
|
||||
for os_class in os['classes']:
|
||||
|
||||
@@ -520,8 +511,8 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
for i in range(len(OSCLASS_HEADER)):
|
||||
|
||||
column = gtk.TreeViewColumn(OSCLASS_HEADER[i],
|
||||
self.__cell,
|
||||
column = Gtk.TreeViewColumn(title=OSCLASS_HEADER[i],
|
||||
cell_renderer=self.__cell,
|
||||
text=i)
|
||||
|
||||
self.__class_column.append(column)
|
||||
@@ -547,8 +538,8 @@ class SystemPage(BWScrolledWindow):
|
||||
self.__fp_ports = BWHBox()
|
||||
self.__fp_label = BWSectionLabel(_('Used ports:'))
|
||||
|
||||
self.__fp_ports_list = gtk.combo_box_entry_new_text()
|
||||
self.__fp_ports_list.child.set_editable(False)
|
||||
self.__fp_ports_list = Gtk.ComboBoxText.new_with_entry()
|
||||
self.__fp_ports_list.get_child().set_editable(False)
|
||||
|
||||
self.__fp_vbox = BWVBox()
|
||||
|
||||
@@ -601,7 +592,7 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
table.attach(tcp_class, 1, 2, 1, 2)
|
||||
|
||||
tcp_values = gtk.combo_box_entry_new_text()
|
||||
tcp_values = Gtk.ComboBoxText.new_with_entry()
|
||||
|
||||
for value in tcp['values']:
|
||||
tcp_values.append_text(value)
|
||||
@@ -626,7 +617,7 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
table.attach(ip_id_class, 1, 2, 2, 3)
|
||||
|
||||
ip_id_values = gtk.combo_box_entry_new_text()
|
||||
ip_id_values = Gtk.ComboBoxText.new_with_entry()
|
||||
|
||||
for value in ip_id['values']:
|
||||
ip_id_values.append_text(value)
|
||||
@@ -644,7 +635,7 @@ class SystemPage(BWScrolledWindow):
|
||||
|
||||
if tcp_ts['values'] is not None:
|
||||
|
||||
tcp_ts_values = gtk.combo_box_entry_new_text()
|
||||
tcp_ts_values = Gtk.ComboBoxText.new_with_entry()
|
||||
|
||||
for value in tcp_ts['values']:
|
||||
tcp_ts_values.append_text(value)
|
||||
@@ -678,8 +669,8 @@ class TraceroutePage(BWVBox):
|
||||
hops = trace.get("hops")
|
||||
if hops is None or len(hops) == 0:
|
||||
|
||||
self.__trace_label = gtk.Label(NO_TRACE_TEXT)
|
||||
self.pack_start(self.__trace_label, True, True)
|
||||
self.__trace_label = Gtk.Label.new(NO_TRACE_TEXT)
|
||||
self.pack_start(self.__trace_label, True, True, 0)
|
||||
|
||||
else:
|
||||
|
||||
@@ -687,19 +678,13 @@ class TraceroutePage(BWVBox):
|
||||
hops = self.__node.get_info('trace')['hops']
|
||||
ttls = [int(i['ttl']) for i in hops]
|
||||
|
||||
self.__cell = gtk.CellRendererText()
|
||||
self.__cell = Gtk.CellRendererText()
|
||||
|
||||
self.__trace_scroll = BWScrolledWindow()
|
||||
self.__trace_scroll.set_border_width(0)
|
||||
|
||||
self.__trace_store = gtk.ListStore(gobject.TYPE_INT,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING,
|
||||
gobject.TYPE_BOOLEAN)
|
||||
|
||||
self.__trace_treeview = gtk.TreeView(self.__trace_store)
|
||||
self.__trace_store = Gtk.ListStore.new([int, str, str, str, str, bool])
|
||||
self.__trace_treeview = Gtk.TreeView.new_with_model(self.__trace_store)
|
||||
|
||||
count = 0
|
||||
|
||||
@@ -729,8 +714,8 @@ class TraceroutePage(BWVBox):
|
||||
|
||||
for i in range(len(TRACE_HEADER)):
|
||||
|
||||
column = gtk.TreeViewColumn(TRACE_HEADER[i],
|
||||
self.__cell,
|
||||
column = Gtk.TreeViewColumn(title=TRACE_HEADER[i],
|
||||
cell_renderer=self.__cell,
|
||||
text=i)
|
||||
|
||||
self.__trace_column.append(column)
|
||||
|
||||
@@ -57,8 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, Pango
|
||||
|
||||
import radialnet.util.drawing as drawing
|
||||
|
||||
@@ -78,13 +80,13 @@ class NodeWindow(BWWindow):
|
||||
def __init__(self, node, position):
|
||||
"""
|
||||
"""
|
||||
BWWindow.__init__(self, gtk.WINDOW_TOPLEVEL)
|
||||
BWWindow.__init__(self, Gtk.WindowType.TOPLEVEL)
|
||||
self.move(position[0], position[1])
|
||||
self.set_default_size(DIMENSION_NORMAL[0], DIMENSION_NORMAL[1])
|
||||
|
||||
self.__node = node
|
||||
|
||||
self.__title_font = pango.FontDescription('Monospace Bold')
|
||||
self.__title_font = Pango.FontDescription('Monospace Bold')
|
||||
|
||||
self.__icon = Application()
|
||||
self.__create_widgets()
|
||||
@@ -100,14 +102,14 @@ class NodeWindow(BWWindow):
|
||||
# create head elements
|
||||
|
||||
# icon with node's score color
|
||||
self.__color_box = gtk.EventBox()
|
||||
self.__color_image = gtk.Image()
|
||||
self.__color_box = Gtk.EventBox()
|
||||
self.__color_image = Gtk.Image()
|
||||
self.__color_image.set_from_file(self.__icon.get_icon('border'))
|
||||
self.__color_box.add(self.__color_image)
|
||||
self.__color_box.set_size_request(15, 15)
|
||||
r, g, b = drawing.cairo_to_gdk_color(
|
||||
self.__node.get_draw_info('color'))
|
||||
self.__color_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(r, g, b))
|
||||
self.__color_box.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(r, g, b))
|
||||
|
||||
# title with the node ip and hostname
|
||||
self.__title = self.__node.get_host().get_hostname()
|
||||
|
||||
@@ -57,10 +57,15 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk
|
||||
|
||||
import math
|
||||
import cairo
|
||||
import gobject
|
||||
|
||||
from functools import reduce
|
||||
|
||||
import radialnet.util.geometry as geometry
|
||||
import radialnet.util.misc as misc
|
||||
@@ -102,7 +107,7 @@ FILE_TYPE_PS = 3
|
||||
FILE_TYPE_SVG = 4
|
||||
|
||||
|
||||
class RadialNet(gtk.DrawingArea):
|
||||
class RadialNet(Gtk.DrawingArea):
|
||||
"""
|
||||
Radial network visualization widget
|
||||
"""
|
||||
@@ -162,7 +167,7 @@ class RadialNet(gtk.DrawingArea):
|
||||
|
||||
super(RadialNet, self).__init__()
|
||||
|
||||
self.connect('expose_event', self.expose)
|
||||
self.connect('draw', self.draw)
|
||||
self.connect('button_press_event', self.button_press)
|
||||
self.connect('button_release_event', self.button_release)
|
||||
self.connect('motion_notify_event', self.motion_notify)
|
||||
@@ -172,19 +177,17 @@ class RadialNet(gtk.DrawingArea):
|
||||
self.connect('key_release_event', self.key_release)
|
||||
self.connect('scroll_event', self.scroll_event)
|
||||
|
||||
self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
|
||||
gtk.gdk.BUTTON_RELEASE_MASK |
|
||||
gtk.gdk.ENTER_NOTIFY |
|
||||
gtk.gdk.LEAVE_NOTIFY |
|
||||
gtk.gdk.MOTION_NOTIFY |
|
||||
gtk.gdk.NOTHING |
|
||||
gtk.gdk.KEY_PRESS_MASK |
|
||||
gtk.gdk.KEY_RELEASE_MASK |
|
||||
gtk.gdk.POINTER_MOTION_HINT_MASK |
|
||||
gtk.gdk.POINTER_MOTION_MASK |
|
||||
gtk.gdk.SCROLL_MASK)
|
||||
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
|
||||
Gdk.EventMask.BUTTON_RELEASE_MASK |
|
||||
Gdk.EventMask.ENTER_NOTIFY_MASK |
|
||||
Gdk.EventMask.LEAVE_NOTIFY_MASK |
|
||||
Gdk.EventMask.KEY_PRESS_MASK |
|
||||
Gdk.EventMask.KEY_RELEASE_MASK |
|
||||
Gdk.EventMask.POINTER_MOTION_HINT_MASK |
|
||||
Gdk.EventMask.POINTER_MOTION_MASK |
|
||||
Gdk.EventMask.SCROLL_MASK)
|
||||
|
||||
self.set_flags(gtk.CAN_FOCUS)
|
||||
self.set_can_focus(True)
|
||||
self.grab_focus()
|
||||
|
||||
def graph_is_not_empty(function):
|
||||
@@ -536,10 +539,10 @@ class RadialNet(gtk.DrawingArea):
|
||||
def scroll_event(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
if event.direction == gtk.gdk.SCROLL_UP:
|
||||
if event.direction == Gdk.ScrollDirection.UP:
|
||||
self.set_scale(self.__scale + 0.01)
|
||||
|
||||
if event.direction == gtk.gdk.SCROLL_DOWN:
|
||||
if event.direction == Gdk.ScrollDirection.DOWN:
|
||||
self.set_scale(self.__scale - 0.01)
|
||||
|
||||
self.queue_draw()
|
||||
@@ -549,7 +552,7 @@ class RadialNet(gtk.DrawingArea):
|
||||
def key_press(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
key = gtk.gdk.keyval_name(event.keyval)
|
||||
key = Gdk.keyval_name(event.keyval)
|
||||
|
||||
if key == 'KP_Add':
|
||||
self.set_ring_gap(self.__ring_gap + 1)
|
||||
@@ -571,7 +574,7 @@ class RadialNet(gtk.DrawingArea):
|
||||
def key_release(self, widget, event):
|
||||
"""
|
||||
"""
|
||||
key = gtk.gdk.keyval_name(event.keyval)
|
||||
key = Gdk.keyval_name(event.keyval)
|
||||
|
||||
if key == 'c':
|
||||
self.__translation = (0, 0)
|
||||
@@ -710,7 +713,8 @@ class RadialNet(gtk.DrawingArea):
|
||||
|
||||
if result is not None:
|
||||
|
||||
xw, yw = self.window.get_origin()
|
||||
# first returned value is not meaningful and should be ignored
|
||||
_, xw, yw = self.get_window().get_origin()
|
||||
node, point = result
|
||||
x, y = point
|
||||
|
||||
@@ -792,19 +796,16 @@ class RadialNet(gtk.DrawingArea):
|
||||
|
||||
return False
|
||||
|
||||
def expose(self, widget, event):
|
||||
def draw(self, widget, context):
|
||||
"""
|
||||
Drawing callback
|
||||
@type widget: GtkWidget
|
||||
@param widget: Gtk widget superclass
|
||||
@type event: GtkEvent
|
||||
@param event: Gtk event of widget
|
||||
@type context: cairo.Context
|
||||
@param context: cairo context class
|
||||
@rtype: boolean
|
||||
@return: Indicator of the event propagation
|
||||
"""
|
||||
context = widget.window.cairo_create()
|
||||
|
||||
context.rectangle(*event.area)
|
||||
context.set_source_rgb(1.0, 1.0, 1.0)
|
||||
context.fill()
|
||||
|
||||
@@ -820,8 +821,8 @@ class RadialNet(gtk.DrawingArea):
|
||||
# getting allocation reference
|
||||
allocation = self.get_allocation()
|
||||
|
||||
self.__center_of_widget = (allocation.width / 2,
|
||||
allocation.height / 2)
|
||||
self.__center_of_widget = (allocation.width // 2,
|
||||
allocation.height // 2)
|
||||
|
||||
xc, yc = self.__center_of_widget
|
||||
|
||||
@@ -1453,9 +1454,9 @@ class RadialNet(gtk.DrawingArea):
|
||||
self.__calc_node_positions()
|
||||
|
||||
# steps for slow-in/slow-out animation
|
||||
steps = range(self.__number_of_frames)
|
||||
steps = list(range(self.__number_of_frames))
|
||||
|
||||
for i in range(len(steps) / 2):
|
||||
for i in range(len(steps) // 2):
|
||||
steps[self.__number_of_frames - 1 - i] = steps[i]
|
||||
|
||||
# normalize angles and calculate interpolated points
|
||||
@@ -1572,7 +1573,7 @@ class RadialNet(gtk.DrawingArea):
|
||||
|
||||
# animation continue condition
|
||||
if index < self.__number_of_frames - 1:
|
||||
gobject.timeout_add(self.__animation_rate, # time to recall
|
||||
GLib.timeout_add(self.__animation_rate, # time to recall
|
||||
self.__livens_up, # recursive call
|
||||
index + 1) # next iteration
|
||||
else:
|
||||
|
||||
@@ -57,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import os.path
|
||||
import radialnet.gui.RadialNet as RadialNet
|
||||
import zenmapGUI.FileChoosers
|
||||
@@ -84,16 +88,16 @@ class SaveDialog(zenmapGUI.FileChoosers.UnicodeFileChooserDialog):
|
||||
"""
|
||||
"""
|
||||
super(SaveDialog, self).__init__(title=_("Save Topology"),
|
||||
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
|
||||
action=Gtk.FileChooserAction.SAVE,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
||||
|
||||
types_store = gtk.ListStore(str, object, str)
|
||||
types_store = Gtk.ListStore.new([str, object, str])
|
||||
for type in TYPES:
|
||||
types_store.append(type)
|
||||
|
||||
self.__combo = gtk.ComboBox(types_store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.__combo = Gtk.ComboBox.new_with_model(types_store)
|
||||
cell = Gtk.CellRendererText()
|
||||
self.__combo.pack_start(cell, True)
|
||||
self.__combo.add_attribute(cell, "text", 0)
|
||||
|
||||
@@ -103,9 +107,9 @@ class SaveDialog(zenmapGUI.FileChoosers.UnicodeFileChooserDialog):
|
||||
self.connect("response", self.__response_cb)
|
||||
|
||||
hbox = HIGHBox()
|
||||
label = gtk.Label(_("Select File Type:"))
|
||||
hbox.pack_end(self.__combo, False)
|
||||
hbox.pack_end(label, False)
|
||||
label = Gtk.Label.new(_("Select File Type:"))
|
||||
hbox.pack_end(self.__combo, False, True, 0)
|
||||
hbox.pack_end(label, False, True, 0)
|
||||
|
||||
self.set_extra_widget(hbox)
|
||||
self.set_do_overwrite_confirmation(True)
|
||||
@@ -131,7 +135,7 @@ class SaveDialog(zenmapGUI.FileChoosers.UnicodeFileChooserDialog):
|
||||
def __response_cb(self, widget, response_id):
|
||||
"""Intercept the "response" signal to check if someone used the "By
|
||||
extension" file type with an unknown extension."""
|
||||
if response_id == gtk.RESPONSE_OK and self.get_filetype() is None:
|
||||
if response_id == Gtk.ResponseType.OK and self.get_filetype() is None:
|
||||
ext = self.__get_extension()
|
||||
if ext == "":
|
||||
filename = self.get_filename() or ""
|
||||
|
||||
@@ -57,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from radialnet.bestwidgets.buttons import BWStockButton, BWToggleStockButton
|
||||
from radialnet.gui.SaveDialog import SaveDialog
|
||||
@@ -73,13 +76,13 @@ HIDE = False
|
||||
REFRESH_RATE = 500
|
||||
|
||||
|
||||
class ToolsMenu(gtk.Menu):
|
||||
class ToolsMenu(Gtk.Menu):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, radialnet):
|
||||
"""
|
||||
"""
|
||||
gtk.Menu.__init__(self)
|
||||
Gtk.Menu.__init__(self)
|
||||
|
||||
self.radialnet = radialnet
|
||||
|
||||
@@ -88,10 +91,10 @@ class ToolsMenu(gtk.Menu):
|
||||
def __create_items(self):
|
||||
"""
|
||||
"""
|
||||
self.__hosts = gtk.ImageMenuItem(_('Hosts viewer'))
|
||||
self.__hosts = Gtk.ImageMenuItem.new_with_label(_('Hosts viewer'))
|
||||
self.__hosts.connect("activate", self.__hosts_viewer_callback)
|
||||
self.__hosts_image = gtk.Image()
|
||||
self.__hosts_image.set_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_MENU)
|
||||
self.__hosts_image = Gtk.Image()
|
||||
self.__hosts_image.set_from_stock(Gtk.STOCK_INDEX, Gtk.IconSize.MENU)
|
||||
self.__hosts.set_image(self.__hosts_image)
|
||||
|
||||
self.append(self.__hosts)
|
||||
@@ -116,13 +119,13 @@ class ToolsMenu(gtk.Menu):
|
||||
self.__hosts.set_sensitive(False)
|
||||
|
||||
|
||||
class Toolbar(gtk.HBox):
|
||||
class Toolbar(Gtk.Box):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, radialnet, window, control, fisheye):
|
||||
"""
|
||||
"""
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
#self.set_style(gtk.TOOLBAR_BOTH_HORIZ)
|
||||
#self.set_tooltips(True)
|
||||
|
||||
@@ -157,22 +160,22 @@ class Toolbar(gtk.HBox):
|
||||
#self.__tools_button.set_menu(self.__tools_menu)
|
||||
#self.__tools_button.connect('clicked', self.__tools_callback)
|
||||
|
||||
self.__save_button = BWStockButton(gtk.STOCK_SAVE, _("Save Graphic"))
|
||||
self.__save_button = BWStockButton(Gtk.STOCK_SAVE, _("Save Graphic"))
|
||||
self.__save_button.connect("clicked", self.__save_image_callback)
|
||||
|
||||
self.__hosts_button = BWStockButton(gtk.STOCK_INDEX, _("Hosts Viewer"))
|
||||
self.__hosts_button = BWStockButton(Gtk.STOCK_INDEX, _("Hosts Viewer"))
|
||||
self.__hosts_button.connect("clicked", self.__hosts_viewer_callback)
|
||||
|
||||
self.__control = BWToggleStockButton(
|
||||
gtk.STOCK_PROPERTIES, _("Controls"))
|
||||
Gtk.STOCK_PROPERTIES, _("Controls"))
|
||||
self.__control.connect('clicked', self.__control_callback)
|
||||
self.__control.set_active(False)
|
||||
|
||||
self.__fisheye = BWToggleStockButton(gtk.STOCK_ZOOM_FIT, _("Fisheye"))
|
||||
self.__fisheye = BWToggleStockButton(Gtk.STOCK_ZOOM_FIT, _("Fisheye"))
|
||||
self.__fisheye.connect('clicked', self.__fisheye_callback)
|
||||
self.__fisheye.set_active(False)
|
||||
|
||||
self.__legend_button = BWStockButton(gtk.STOCK_INDEX, _("Legend"))
|
||||
self.__legend_button = BWStockButton(Gtk.STOCK_INDEX, _("Legend"))
|
||||
self.__legend_button.connect('clicked', self.__legend_callback)
|
||||
|
||||
#self.__fullscreen = gtk.ToggleToolButton(gtk.STOCK_FULLSCREEN)
|
||||
@@ -187,8 +190,8 @@ class Toolbar(gtk.HBox):
|
||||
#self.__about.connect('clicked', self.__about_callback)
|
||||
#self.__about.set_tooltip(self.__tooltips, _('About RadialNet'))
|
||||
|
||||
self.__separator = gtk.SeparatorToolItem()
|
||||
self.__expander = gtk.SeparatorToolItem()
|
||||
self.__separator = Gtk.SeparatorToolItem()
|
||||
self.__expander = Gtk.SeparatorToolItem()
|
||||
self.__expander.set_expand(True)
|
||||
self.__expander.set_draw(False)
|
||||
|
||||
@@ -202,11 +205,11 @@ class Toolbar(gtk.HBox):
|
||||
#self.insert(self.__about, 7)
|
||||
|
||||
#self.pack_start(self.__tools_button, False)
|
||||
self.pack_start(self.__hosts_button, False)
|
||||
self.pack_start(self.__fisheye, False)
|
||||
self.pack_start(self.__control, False)
|
||||
self.pack_end(self.__save_button, False)
|
||||
self.pack_end(self.__legend_button, False)
|
||||
self.pack_start(self.__hosts_button, False, True, 0)
|
||||
self.pack_start(self.__fisheye, False, True, 0)
|
||||
self.pack_start(self.__control, False, True, 0)
|
||||
self.pack_end(self.__save_button, False, True, 0)
|
||||
self.pack_end(self.__legend_button, False, True, 0)
|
||||
|
||||
def disable_controls(self):
|
||||
"""
|
||||
@@ -246,17 +249,17 @@ class Toolbar(gtk.HBox):
|
||||
|
||||
response = self.__save_chooser.run()
|
||||
|
||||
if response == gtk.RESPONSE_OK:
|
||||
if response == Gtk.ResponseType.OK:
|
||||
filename = self.__save_chooser.get_filename()
|
||||
filetype = self.__save_chooser.get_filetype()
|
||||
|
||||
try:
|
||||
self.radialnet.save_drawing_to_file(filename, filetype)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
alert = HIGAlertDialog(parent=self.__save_chooser,
|
||||
type=gtk.MESSAGE_ERROR,
|
||||
type=Gtk.MessageType.ERROR,
|
||||
message_format=_("Error saving snapshot"),
|
||||
secondary_text=unicode(e))
|
||||
secondary_text=str(e))
|
||||
alert.run()
|
||||
alert.destroy()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# vim: set fileencoding=utf-8 :
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
def cairo_to_gdk_color(color):
|
||||
"""
|
||||
"""
|
||||
new_color = range(len(color))
|
||||
new_color = list(range(len(color)))
|
||||
|
||||
for i in range(len(color)):
|
||||
new_color[i] = int(color[i] * 65535)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -59,8 +58,8 @@
|
||||
# ***************************************************************************/
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 2:
|
||||
sys.exit("Sorry, Zenmap requires Python 2")
|
||||
if sys.version_info[0] != 3:
|
||||
sys.exit("Sorry, Zenmap requires Python 3")
|
||||
|
||||
import errno
|
||||
import os
|
||||
@@ -127,7 +126,7 @@ data_files = [
|
||||
]
|
||||
|
||||
# Add i18n files to data_files list
|
||||
os.path.walk(locale_dir, mo_find, data_files)
|
||||
os.walk(locale_dir, mo_find, data_files)
|
||||
|
||||
|
||||
# path_startswith and path_strip_prefix are used to deal with the installation
|
||||
@@ -213,7 +212,7 @@ class my_install(install):
|
||||
self.install_scripts, "uninstall_" + APP_NAME)
|
||||
|
||||
uninstaller = """\
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import errno, os, os.path, sys
|
||||
|
||||
print 'Uninstall %(name)s %(version)s'
|
||||
@@ -266,7 +265,7 @@ for file in files:
|
||||
print "Removing '%s'." % file
|
||||
try:
|
||||
os.remove(file)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
print >> sys.stderr, ' Error: %s.' % str(e)
|
||||
# Delete the directories. First reverse-sort the normalized paths by
|
||||
# length so that child directories are deleted before their parents.
|
||||
@@ -276,7 +275,7 @@ for dir in dirs:
|
||||
try:
|
||||
print "Removing the directory '%s'." % dir
|
||||
os.rmdir(dir)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOTEMPTY:
|
||||
print "Directory '%s' not empty; not removing." % dir
|
||||
else:
|
||||
@@ -288,7 +287,7 @@ for dir in dirs:
|
||||
uninstaller_file.close()
|
||||
|
||||
# Set exec bit for uninstaller
|
||||
mode = ((os.stat(uninstaller_filename)[ST_MODE]) | 0555) & 07777
|
||||
mode = ((os.stat(uninstaller_filename)[ST_MODE]) | 0o555) & 0o7777
|
||||
os.chmod(uninstaller_filename, mode)
|
||||
|
||||
def set_modules_path(self):
|
||||
@@ -442,7 +441,7 @@ class my_uninstall(Command):
|
||||
# Read the list of installed files.
|
||||
try:
|
||||
f = open(INSTALLED_FILES_NAME, "r")
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
log.error("Couldn't open the installation record '%s'. "
|
||||
"Have you installed yet?" % INSTALLED_FILES_NAME)
|
||||
@@ -465,7 +464,7 @@ class my_uninstall(Command):
|
||||
try:
|
||||
if not self.dry_run:
|
||||
os.remove(file)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
log.error(str(e))
|
||||
# Delete the directories. First reverse-sort the normalized paths by
|
||||
# length so that child directories are deleted before their parents.
|
||||
@@ -476,7 +475,7 @@ class my_uninstall(Command):
|
||||
log.info("Removing the directory '%s'." % dir)
|
||||
if not self.dry_run:
|
||||
os.rmdir(dir)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOTEMPTY:
|
||||
log.info("Directory '%s' not empty; not removing." % dir)
|
||||
else:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This program acts like xgettext, specialized to extract strings from Zenmap's
|
||||
# profile_editor.xml file.
|
||||
@@ -21,10 +21,10 @@ def escape(s):
|
||||
|
||||
|
||||
def output_msgid(msgid, locator):
|
||||
print
|
||||
print u"#: %s:%d" % (locator.getSystemId(), locator.getLineNumber())
|
||||
print u"msgid", escape(msgid)
|
||||
print u"msgstr", escape(u"")
|
||||
print()
|
||||
print("#: %s:%d" % (locator.getSystemId(), locator.getLineNumber()))
|
||||
print("msgid", escape(msgid))
|
||||
print("msgstr", escape(""))
|
||||
|
||||
|
||||
class Handler (xml.sax.handler.ContentHandler):
|
||||
@@ -32,12 +32,12 @@ class Handler (xml.sax.handler.ContentHandler):
|
||||
self.locator = locator
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
if name == u"group":
|
||||
output_msgid(attrs[u"name"], self.locator)
|
||||
if attrs.get(u"short_desc"):
|
||||
output_msgid(attrs[u"short_desc"], self.locator)
|
||||
if attrs.get(u"label"):
|
||||
output_msgid(attrs[u"label"], self.locator)
|
||||
if name == "group":
|
||||
output_msgid(attrs["name"], self.locator)
|
||||
if attrs.get("short_desc"):
|
||||
output_msgid(attrs["short_desc"], self.locator)
|
||||
if attrs.get("label"):
|
||||
output_msgid(attrs["label"], self.locator)
|
||||
|
||||
opts, filenames = getopt.gnu_getopt(sys.argv[1:], "D:", ["directory="])
|
||||
for o, a in opts:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -111,15 +110,15 @@ if INSTALL_LIB is not None and is_secure_dir(INSTALL_LIB):
|
||||
|
||||
try:
|
||||
import zenmapGUI.App
|
||||
except ImportError, e:
|
||||
print >> sys.stderr, """\
|
||||
except ImportError as e:
|
||||
print("""\
|
||||
Could not import the zenmapGUI.App module: %s.
|
||||
I checked in these directories:""" % repr(e.message)
|
||||
I checked in these directories:""" % repr(e.message), file=sys.stderr)
|
||||
for dir in sys.path:
|
||||
print >> sys.stderr, " %s" % dir
|
||||
print >> sys.stderr, """\
|
||||
print(" %s" % dir, file=sys.stderr)
|
||||
print("""\
|
||||
If you installed Zenmap in another directory, you may have to add the
|
||||
modules directory to the PYTHONPATH environment variable."""
|
||||
modules directory to the PYTHONPATH environment variable.""", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -65,7 +64,7 @@ import sys
|
||||
from zenmapCore.Name import APP_NAME
|
||||
|
||||
|
||||
def fs_dec(s):
|
||||
def fs_dec(s): # This is unused now
|
||||
"""Decode s from the filesystem decoding, handling various possible
|
||||
errors."""
|
||||
enc = sys.getfilesystemencoding()
|
||||
@@ -88,7 +87,7 @@ def fs_enc(u):
|
||||
# systems like Windows where the file system encoding is different from the
|
||||
# result of sys.getdefaultencoding(). So we call os.path.expanduser with a
|
||||
# plain string and decode it from the filesystem encoding.
|
||||
HOME = fs_dec(os.path.expanduser("~"))
|
||||
HOME = os.path.expanduser("~")
|
||||
|
||||
# The base_paths dict in this file gives symbolic names to various files. For
|
||||
# example, use base_paths.target_list instead of 'target_list.txt'.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -103,10 +102,10 @@ def install_gettext(locale_dir):
|
||||
else:
|
||||
t = gettext.translation(
|
||||
APP_NAME, locale_dir, languages=get_locales(), fallback=True)
|
||||
t.install(unicode=True)
|
||||
t.install()
|
||||
|
||||
# Install a dummy _ function so modules can safely use it after importing this
|
||||
# module, even if they don't install the gettext version.
|
||||
|
||||
import __builtin__
|
||||
__builtin__.__dict__["_"] = lambda s: s
|
||||
import builtins
|
||||
builtins.__dict__["_"] = lambda s: s
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -69,7 +68,7 @@ APP_DOWNLOAD_SITE = "https://nmap.org/download.html"
|
||||
APP_DOCUMENTATION_SITE = "https://nmap.org/book/zenmap.html"
|
||||
APP_COPYRIGHT = "Copyright 2005-2022 Nmap Software LLC"
|
||||
|
||||
NMAP_DISPLAY_NAME = u"Nmap"
|
||||
NMAP_DISPLAY_NAME = "Nmap"
|
||||
NMAP_WEB_SITE = "https://nmap.org"
|
||||
|
||||
UMIT_DISPLAY_NAME = "Umit"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -63,7 +62,7 @@ import unittest
|
||||
import zenmapCore
|
||||
import zenmapCore.NmapParser
|
||||
from zenmapGUI.SearchGUI import SearchParser
|
||||
from SearchResult import HostSearch
|
||||
from .SearchResult import HostSearch
|
||||
|
||||
|
||||
class NetworkInventory(object):
|
||||
@@ -255,13 +254,13 @@ class NetworkInventory(object):
|
||||
return self.scans
|
||||
|
||||
def get_hosts(self):
|
||||
return self.hosts.values()
|
||||
return list(self.hosts.values())
|
||||
|
||||
def get_hosts_up(self):
|
||||
return filter(lambda h: h.get_state() == 'up', self.hosts.values())
|
||||
return [h for h in list(self.hosts.values()) if h.get_state() == 'up']
|
||||
|
||||
def get_hosts_down(self):
|
||||
return filter(lambda h: h.get_state() == 'down', self.hosts.values())
|
||||
return [h for h in list(self.hosts.values()) if h.get_state() == 'down']
|
||||
|
||||
def open_from_file(self, path):
|
||||
"""Loads a scan from the given file."""
|
||||
@@ -353,7 +352,7 @@ class NetworkInventory(object):
|
||||
a list of (full-path) filenames that were used to save the scans."""
|
||||
self._generate_filenames(path)
|
||||
|
||||
for scan, filename in self.filenames.iteritems():
|
||||
for scan, filename in self.filenames.items():
|
||||
f = open(os.path.join(path, filename), "w")
|
||||
scan.write_xml(f)
|
||||
f.close()
|
||||
@@ -367,7 +366,7 @@ class NetworkInventory(object):
|
||||
# For now, this saves each scan making up the inventory separately in
|
||||
# the database.
|
||||
from time import time
|
||||
from cStringIO import StringIO
|
||||
from io import StringIO
|
||||
from zenmapCore.UmitDB import Scans
|
||||
|
||||
for parsed in self.get_scans():
|
||||
@@ -424,15 +423,13 @@ class FilteredNetworkInventory(NetworkInventory):
|
||||
|
||||
def get_hosts_up(self):
|
||||
if len(self.search_dict) > 0:
|
||||
return filter(lambda h: h.get_state() == 'up',
|
||||
self.filtered_hosts)
|
||||
return [h for h in self.filtered_hosts if h.get_state() == 'up']
|
||||
else:
|
||||
return NetworkInventory.get_hosts_up(self)
|
||||
|
||||
def get_hosts_down(self):
|
||||
if len(self.search_dict) > 0:
|
||||
return filter(lambda h: h.get_state() == 'down',
|
||||
self.filtered_hosts)
|
||||
return [h for h in self.filtered_hosts if h.get_state() == 'down']
|
||||
else:
|
||||
return NetworkInventory.get_hosts_down(self)
|
||||
|
||||
@@ -508,10 +505,10 @@ class FilteredNetworkInventory(NetworkInventory):
|
||||
self.filter_text = filter_text.lower()
|
||||
self.search_parser.update(self.filter_text)
|
||||
self.filtered_hosts = []
|
||||
for hostname, host in self.hosts.iteritems():
|
||||
for hostname, host in self.hosts.items():
|
||||
# For each host in this scan
|
||||
# Test each given operator against the current host
|
||||
for operator, args in self.search_dict.iteritems():
|
||||
for operator, args in self.search_dict.items():
|
||||
if not self._match_all_args(host, operator, args):
|
||||
# No match => we discard this scan_result
|
||||
break
|
||||
@@ -582,7 +579,7 @@ class NetworkInventoryTest(unittest.TestCase):
|
||||
inv.remove_scan(scan_3)
|
||||
except Exception:
|
||||
pass
|
||||
self.assertEqual(added_ips, inv.hosts.keys())
|
||||
self.assertEqual(added_ips, list(inv.hosts.keys()))
|
||||
self.assertEqual(host_a.hostnames, ["a"])
|
||||
self.assertEqual(host_b.hostnames, ["b"])
|
||||
|
||||
@@ -646,7 +643,7 @@ if __name__ == "__main__":
|
||||
inventory1.add_scan(scan2)
|
||||
|
||||
for host in inventory1.get_hosts():
|
||||
print "%s" % host.ip["addr"],
|
||||
print("%s" % host.ip["addr"], end=' ')
|
||||
#if len(host.hostnames) > 0:
|
||||
# print "[%s]:" % host.hostnames[0]["hostname"]
|
||||
#else:
|
||||
@@ -662,12 +659,12 @@ if __name__ == "__main__":
|
||||
inventory1.remove_scan(scan2)
|
||||
print
|
||||
for host in inventory1.get_hosts():
|
||||
print "%s" % host.ip["addr"],
|
||||
print("%s" % host.ip["addr"], end=' ')
|
||||
|
||||
inventory1.add_scan(scan2)
|
||||
print
|
||||
for host in inventory1.get_hosts():
|
||||
print "%s" % host.ip["addr"],
|
||||
print("%s" % host.ip["addr"], end=' ')
|
||||
|
||||
dir = "/home/ndwi/scanz/top01"
|
||||
inventory1.save_to_dir(dir)
|
||||
@@ -675,6 +672,6 @@ if __name__ == "__main__":
|
||||
inventory2 = NetworkInventory()
|
||||
inventory2.open_from_dir(dir)
|
||||
|
||||
print
|
||||
print()
|
||||
for host in inventory2.get_hosts():
|
||||
print "%s" % host.ip["addr"],
|
||||
print("%s" % host.ip["addr"], end=' ')
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -73,7 +72,7 @@ import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
try:
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + ".\n" + _("Python 2.4 or later is required."))
|
||||
|
||||
import zenmapCore.Paths
|
||||
@@ -183,7 +182,7 @@ class NmapCommand(object):
|
||||
if self.xml_is_temp:
|
||||
try:
|
||||
os.remove(self.xml_output_filename)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This is an Nmap command line parser. It has two main parts:
|
||||
#
|
||||
@@ -539,7 +539,7 @@ class NmapOptions(object):
|
||||
return self.d.setdefault(self.canonicalize_name(key), default)
|
||||
|
||||
def handle_result(self, result):
|
||||
if isinstance(result, basestring):
|
||||
if isinstance(result, str):
|
||||
# A positional argument.
|
||||
self.target_specs.append(result)
|
||||
return
|
||||
@@ -640,7 +640,7 @@ class NmapOptions(object):
|
||||
self["-d"] = int(arg)
|
||||
except ValueError:
|
||||
if reduce(lambda x, y: x and y,
|
||||
map(lambda z: z == "d", arg), True):
|
||||
[z == "d" for z in arg], True):
|
||||
self.setdefault("-d", 0)
|
||||
self["-d"] += len(arg) + 1
|
||||
else:
|
||||
@@ -720,7 +720,7 @@ class NmapOptions(object):
|
||||
self["-v"] = -1
|
||||
except ValueError:
|
||||
if reduce(lambda x, y: x and y,
|
||||
map(lambda z: z == "v", arg), True):
|
||||
[z == "v" for z in arg], True):
|
||||
self.setdefault("-v", 0)
|
||||
self["-v"] += len(arg) + 1
|
||||
else:
|
||||
@@ -763,7 +763,7 @@ class NmapOptions(object):
|
||||
opt_list.append("-T%s" % str(self["-T"]))
|
||||
|
||||
if self["-O"] is not None:
|
||||
if isinstance(self["-O"], basestring):
|
||||
if isinstance(self["-O"], str):
|
||||
opt_list.append("-O%s" % self["-O"])
|
||||
elif self["-O"]:
|
||||
opt_list.append("-O")
|
||||
@@ -815,7 +815,7 @@ class NmapOptions(object):
|
||||
if self[ping_option] is not None:
|
||||
opt_list.append(ping_option + self[ping_option])
|
||||
if self["-PB"] is not None:
|
||||
if isinstance(self["-PB"], basestring):
|
||||
if isinstance(self["-PB"], str):
|
||||
opt_list.append("-PB" + self["-PB"])
|
||||
elif self["-PB"]:
|
||||
opt_list.append("-PB")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -63,11 +62,7 @@ import time
|
||||
import socket
|
||||
import copy
|
||||
|
||||
# Use the faster cStringIO if available, fallback on StringIO if not
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from StringIO import StringIO
|
||||
from io import StringIO
|
||||
|
||||
# Prevent loading PyXML
|
||||
import xml
|
||||
@@ -558,12 +553,7 @@ in epoch format!")
|
||||
return ports
|
||||
|
||||
def get_formatted_date(self):
|
||||
try:
|
||||
return time.strftime("%B %d, %Y - %H:%M", self.get_date()).decode(
|
||||
locale.getpreferredencoding())
|
||||
except LookupError:
|
||||
# encoding or locale not found
|
||||
return time.asctime(self.get_date()).decode('ascii')
|
||||
return time.strftime("%B %d, %Y - %H:%M", self.get_date())
|
||||
|
||||
def get_scanner(self):
|
||||
return self.nmap['nmaprun'].get('scanner', '')
|
||||
@@ -1333,25 +1323,25 @@ if __name__ == '__main__':
|
||||
np.parse_file(file_to_parse)
|
||||
|
||||
for host in np.hosts:
|
||||
print "%s:" % host.ip["addr"]
|
||||
print " Comment:", repr(host.comment)
|
||||
print " TCP sequence:", repr(host.tcpsequence)
|
||||
print " TCP TS sequence:", repr(host.tcptssequence)
|
||||
print " IP ID sequence:", repr(host.ipidsequence)
|
||||
print " Uptime:", repr(host.uptime)
|
||||
print " OS Match:", repr(host.osmatches)
|
||||
print " Ports:"
|
||||
print("%s:" % host.ip["addr"])
|
||||
print(" Comment:", repr(host.comment))
|
||||
print(" TCP sequence:", repr(host.tcpsequence))
|
||||
print(" TCP TS sequence:", repr(host.tcptssequence))
|
||||
print(" IP ID sequence:", repr(host.ipidsequence))
|
||||
print(" Uptime:", repr(host.uptime))
|
||||
print(" OS Match:", repr(host.osmatches))
|
||||
print(" Ports:")
|
||||
for p in host.ports:
|
||||
print "\t%s" % repr(p)
|
||||
print " Ports used:", repr(host.ports_used)
|
||||
print " OS Matches:", repr(host.osmatches)
|
||||
print " Hostnames:", repr(host.hostnames)
|
||||
print " IP:", repr(host.ip)
|
||||
print " IPv6:", repr(host.ipv6)
|
||||
print " MAC:", repr(host.mac)
|
||||
print " State:", repr(host.state)
|
||||
print("\t%s" % repr(p))
|
||||
print(" Ports used:", repr(host.ports_used))
|
||||
print(" OS Matches:", repr(host.osmatches))
|
||||
print(" Hostnames:", repr(host.hostnames))
|
||||
print(" IP:", repr(host.ip))
|
||||
print(" IPv6:", repr(host.ipv6))
|
||||
print(" MAC:", repr(host.mac))
|
||||
print(" State:", repr(host.state))
|
||||
if "hops" in host.trace:
|
||||
print " Trace:"
|
||||
print(" Trace:")
|
||||
for hop in host.trace["hops"]:
|
||||
print " ", repr(hop)
|
||||
print
|
||||
print(" ", repr(hop))
|
||||
print()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,7 +65,7 @@ import os.path
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
from zenmapCore.BasePaths import base_paths, fs_dec
|
||||
from zenmapCore.BasePaths import base_paths
|
||||
from zenmapCore.Name import APP_NAME
|
||||
|
||||
|
||||
@@ -79,14 +78,14 @@ def get_prefix():
|
||||
frozen = getattr(sys, "frozen", None)
|
||||
if frozen == "macosx_app" or "Zenmap.app" in sys.executable:
|
||||
# A py2app .app bundle.
|
||||
return os.path.join(dirname(fs_dec(sys.executable)), "..", "Resources")
|
||||
return os.path.join(dirname(sys.executable), "..", "Resources")
|
||||
elif frozen is not None:
|
||||
# Assume a py2exe executable.
|
||||
return dirname(fs_dec(sys.executable))
|
||||
return dirname(sys.executable)
|
||||
else:
|
||||
# Normal script execution. Look in the current directory to allow
|
||||
# running from the distribution.
|
||||
return os.path.abspath(os.path.dirname(fs_dec(sys.argv[0])))
|
||||
return os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
|
||||
prefix = get_prefix()
|
||||
|
||||
@@ -182,7 +181,7 @@ def create_dir(path):
|
||||
directory already exists."""
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
@@ -224,19 +223,19 @@ def return_if_exists(path, create=False):
|
||||
Path = Paths()
|
||||
|
||||
if __name__ == '__main__':
|
||||
print ">>> SAVED DIRECTORIES:"
|
||||
print ">>> LOCALE DIR:", Path.locale_dir
|
||||
print ">>> PIXMAPS DIR:", Path.pixmaps_dir
|
||||
print ">>> CONFIG DIR:", Path.config_dir
|
||||
print
|
||||
print ">>> FILES:"
|
||||
print ">>> USER CONFIG FILE:", Path.user_config_file
|
||||
print ">>> CONFIG FILE:", Path.user_config_file
|
||||
print ">>> TARGET_LIST:", Path.target_list
|
||||
print ">>> PROFILE_EDITOR:", Path.profile_editor
|
||||
print ">>> SCAN_PROFILE:", Path.scan_profile
|
||||
print ">>> RECENT_SCANS:", Path.recent_scans
|
||||
print ">>> OPTIONS:", Path.options
|
||||
print
|
||||
print ">>> DB:", Path.db
|
||||
print ">>> VERSION:", Path.version
|
||||
print(">>> SAVED DIRECTORIES:")
|
||||
print(">>> LOCALE DIR:", Path.locale_dir)
|
||||
print(">>> PIXMAPS DIR:", Path.pixmaps_dir)
|
||||
print(">>> CONFIG DIR:", Path.config_dir)
|
||||
print()
|
||||
print(">>> FILES:")
|
||||
print(">>> USER CONFIG FILE:", Path.user_config_file)
|
||||
print(">>> CONFIG FILE:", Path.user_config_file)
|
||||
print(">>> TARGET_LIST:", Path.target_list)
|
||||
print(">>> PROFILE_EDITOR:", Path.profile_editor)
|
||||
print(">>> SCAN_PROFILE:", Path.scan_profile)
|
||||
print(">>> RECENT_SCANS:", Path.recent_scans)
|
||||
print(">>> OPTIONS:", Path.options)
|
||||
print()
|
||||
print(">>> DB:", Path.db)
|
||||
print(">>> VERSION:", Path.version)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -113,7 +112,7 @@ recent_scans = RecentScans()
|
||||
|
||||
if __name__ == "__main__":
|
||||
r = RecentScans()
|
||||
print ">>> Getting empty list:", r.get_recent_scans_list()
|
||||
print ">>> Adding recent scan bla:", r.add_recent_scan("bla")
|
||||
print ">>> Getting recent scan list:", r.get_recent_scans_list()
|
||||
print(">>> Getting empty list:", r.get_recent_scans_list())
|
||||
print(">>> Adding recent scan bla:", r.add_recent_scan("bla"))
|
||||
print(">>> Getting recent scan list:", r.get_recent_scans_list())
|
||||
del r
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -188,21 +188,21 @@ if __name__ == '__main__':
|
||||
|
||||
for test, expected in TESTS:
|
||||
args_dict = parse_script_args_dict(test)
|
||||
print args_dict
|
||||
print(args_dict)
|
||||
args = parse_script_args(test)
|
||||
if args == expected:
|
||||
print "PASS", test
|
||||
print("PASS", test)
|
||||
continue
|
||||
print "FAIL", test
|
||||
print("FAIL", test)
|
||||
if args is None:
|
||||
print "Parsing error"
|
||||
print("Parsing error")
|
||||
else:
|
||||
print "%d args" % len(args)
|
||||
print("%d args" % len(args))
|
||||
for a, v in args:
|
||||
print a, "=", v
|
||||
print(a, "=", v)
|
||||
if expected is None:
|
||||
print "Expected parsing error"
|
||||
print("Expected parsing error")
|
||||
else:
|
||||
print "Expected %d args" % len(expected)
|
||||
print("Expected %d args" % len(expected))
|
||||
for a, v in expected:
|
||||
print a, "=", v
|
||||
print(a, "=", v)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -438,16 +438,16 @@ def get_script_entries(scripts_dir, nselib_dir):
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
for entry in get_script_entries(sys.argv[1], sys.argv[2]):
|
||||
print "*" * 75
|
||||
print "Filename:", entry.filename
|
||||
print "Categories:", entry.categories
|
||||
print "License:", entry.license
|
||||
print "Author:", entry.author
|
||||
print "URL:", entry.url
|
||||
print "Description:", entry.description
|
||||
print "Arguments:", [x[0] for x in entry.arguments]
|
||||
print "Output:"
|
||||
print entry.output
|
||||
print "Usage:"
|
||||
print entry.usage
|
||||
print "*" * 75
|
||||
print("*" * 75)
|
||||
print("Filename:", entry.filename)
|
||||
print("Categories:", entry.categories)
|
||||
print("License:", entry.license)
|
||||
print("Author:", entry.author)
|
||||
print("URL:", entry.url)
|
||||
print("Description:", entry.description)
|
||||
print("Arguments:", [x[0] for x in entry.arguments])
|
||||
print("Output:")
|
||||
print(entry.output)
|
||||
print("Usage:")
|
||||
print(entry.usage)
|
||||
print("*" * 75)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -61,11 +60,10 @@
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import StringIO
|
||||
import io
|
||||
import unittest
|
||||
|
||||
from glob import glob
|
||||
from types import StringTypes
|
||||
|
||||
from zenmapCore.Name import APP_NAME
|
||||
from zenmapCore.NmapOptions import NmapOptions
|
||||
@@ -170,7 +168,7 @@ class SearchResult(object):
|
||||
self.parsed_scan = scan_result
|
||||
|
||||
# Test each given operator against the current parsed result
|
||||
for operator, args in kargs.iteritems():
|
||||
for operator, args in kargs.items():
|
||||
if not self._match_all_args(operator, args):
|
||||
# No match => we discard this scan_result
|
||||
break
|
||||
@@ -319,7 +317,7 @@ class SearchResult(object):
|
||||
return True
|
||||
|
||||
# Transform a comma-delimited string containing ports into a list
|
||||
ports = filter(lambda not_empty: not_empty, ports.split(","))
|
||||
ports = [not_empty for not_empty in ports.split(",") if not_empty]
|
||||
|
||||
# Check if they're parsable, if not return False silently
|
||||
for port in ports:
|
||||
@@ -356,7 +354,7 @@ class SearchResult(object):
|
||||
log.debug("Match port:%s" % ports)
|
||||
|
||||
# Transform a comma-delimited string containing ports into a list
|
||||
ports = filter(lambda not_empty: not_empty, ports.split(","))
|
||||
ports = [not_empty for not_empty in ports.split(",") if not_empty]
|
||||
|
||||
for host in self.parsed_scan.get_hosts():
|
||||
for port in ports:
|
||||
@@ -442,11 +440,11 @@ class SearchDB(SearchResult, object):
|
||||
log.debug(">>> Nmap xml output: %s" % scan.nmap_xml_output)
|
||||
|
||||
try:
|
||||
buffer = StringIO.StringIO(scan.nmap_xml_output)
|
||||
buffer = io.StringIO(scan.nmap_xml_output)
|
||||
parsed = NmapParser()
|
||||
parsed.parse(buffer)
|
||||
buffer.close()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
log.warning(">>> Error loading scan with ID %u from database: "
|
||||
"%s" % (scan.scans_id, str(e)))
|
||||
else:
|
||||
@@ -462,7 +460,7 @@ class SearchDir(SearchResult, object):
|
||||
log.debug(">>> SearchDir initialized")
|
||||
self.search_directory = search_directory
|
||||
|
||||
if isinstance(file_extensions, StringTypes):
|
||||
if isinstance(file_extensions, str):
|
||||
self.file_extensions = file_extensions.split(";")
|
||||
elif isinstance(file_extensions, list):
|
||||
self.file_extensions = file_extensions
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -114,7 +113,7 @@ target_list = TargetList()
|
||||
|
||||
if __name__ == "__main__":
|
||||
t = TargetList()
|
||||
print ">>> Getting empty list:", t.get_target_list()
|
||||
print ">>> Adding target 127.0.0.1:", t.add_target("127.0.0.3")
|
||||
print ">>> Getting target list:", t.get_target_list()
|
||||
print(">>> Getting empty list:", t.get_target_list())
|
||||
print(">>> Adding target 127.0.0.1:", t.add_target("127.0.0.3"))
|
||||
print(">>> Getting target list:", t.get_target_list())
|
||||
del t
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -60,9 +59,8 @@
|
||||
|
||||
import re
|
||||
|
||||
from types import StringTypes
|
||||
from ConfigParser import DuplicateSectionError, NoSectionError, NoOptionError
|
||||
from ConfigParser import Error as ConfigParser_Error
|
||||
from configparser import DuplicateSectionError, NoSectionError, NoOptionError
|
||||
from configparser import Error as ConfigParser_Error
|
||||
|
||||
from zenmapCore.Paths import Path
|
||||
from zenmapCore.UmitLogging import log
|
||||
@@ -107,7 +105,7 @@ class SearchConfig(UmitConfigParser, object):
|
||||
self.search_db = True
|
||||
|
||||
def _get_it(self, p_name, default):
|
||||
return config_parser.get(self.section_name, p_name, default)
|
||||
return config_parser.get(self.section_name, p_name, fallback=default)
|
||||
|
||||
def _set_it(self, p_name, value):
|
||||
config_parser.set(self.section_name, p_name, value)
|
||||
@@ -117,10 +115,8 @@ class SearchConfig(UmitConfigParser, object):
|
||||
attr == "True" or \
|
||||
attr == "true" or \
|
||||
attr == "1":
|
||||
|
||||
return 1
|
||||
|
||||
return 0
|
||||
return "True"
|
||||
return "False"
|
||||
|
||||
def get_directory(self):
|
||||
return self._get_it("directory", "")
|
||||
@@ -134,7 +130,7 @@ class SearchConfig(UmitConfigParser, object):
|
||||
def set_file_extension(self, file_extension):
|
||||
if isinstance(file_extension, list):
|
||||
self._set_it("file_extension", ";".join(file_extension))
|
||||
elif isinstance(file_extension, StringTypes):
|
||||
elif isinstance(file_extension, str):
|
||||
self._set_it("file_extension", file_extension)
|
||||
|
||||
def get_save_time(self):
|
||||
@@ -143,7 +139,7 @@ class SearchConfig(UmitConfigParser, object):
|
||||
def set_save_time(self, save_time):
|
||||
if isinstance(save_time, list):
|
||||
self._set_it("save_time", ";".join(save_time))
|
||||
elif isinstance(save_time, StringTypes):
|
||||
elif isinstance(save_time, str):
|
||||
self._set_it("save_time", save_time)
|
||||
|
||||
def get_store_results(self):
|
||||
@@ -272,7 +268,7 @@ class WindowConfig(UmitConfigParser, object):
|
||||
self.height = self.default_height
|
||||
|
||||
def _get_it(self, p_name, default):
|
||||
return config_parser.get(self.section_name, p_name, default)
|
||||
return config_parser.get(self.section_name, p_name, fallback=default)
|
||||
|
||||
def _set_it(self, p_name, value):
|
||||
config_parser.set(self.section_name, p_name, value)
|
||||
@@ -401,7 +397,7 @@ class NmapOutputHighlight(object):
|
||||
try:
|
||||
return self.sanity_settings([
|
||||
config_parser.get(
|
||||
property_name, prop, True) for prop in self.setts])
|
||||
property_name, prop, raw=True) for prop in self.setts])
|
||||
except Exception:
|
||||
settings = []
|
||||
prop_settings = self.default_highlights[p_name]
|
||||
@@ -420,7 +416,7 @@ class NmapOutputHighlight(object):
|
||||
property_name = "%s_highlight" % property_name
|
||||
settings = self.sanity_settings(list(settings))
|
||||
|
||||
for pos in xrange(len(settings)):
|
||||
for pos in range(len(settings)):
|
||||
config_parser.set(property_name, self.setts[pos], settings[pos])
|
||||
|
||||
def sanity_settings(self, settings):
|
||||
@@ -437,13 +433,13 @@ class NmapOutputHighlight(object):
|
||||
settings[1] = self.boolean_sanity(settings[1])
|
||||
settings[2] = self.boolean_sanity(settings[2])
|
||||
|
||||
tuple_regex = "[\(\[]\s?(\d+)\s?,\s?(\d+)\s?,\s?(\d+)\s?[\)\]]"
|
||||
if isinstance(settings[3], basestring):
|
||||
tuple_regex = r"[\(\[]\s?(\d+)\s?,\s?(\d+)\s?,\s?(\d+)\s?[\)\]]"
|
||||
if isinstance(settings[3], str):
|
||||
settings[3] = [
|
||||
int(t) for t in re.findall(tuple_regex, settings[3])[0]
|
||||
]
|
||||
|
||||
if isinstance(settings[4], basestring):
|
||||
if isinstance(settings[4], str):
|
||||
settings[4] = [
|
||||
int(h) for h in re.findall(tuple_regex, settings[4])[0]
|
||||
]
|
||||
@@ -542,57 +538,57 @@ class NmapOutputHighlight(object):
|
||||
"underline": str(False),
|
||||
"text": [0, 0, 0],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}\s.{1,4}"},
|
||||
"regex": r"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}\s.{1,4}"},
|
||||
"hostname": {
|
||||
"bold": str(True),
|
||||
"italic": str(True),
|
||||
"underline": str(True),
|
||||
"text": [0, 111, 65535],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "(\w{2,}://)*[\w-]{2,}\.[\w-]{2,}"
|
||||
"(\.[\w-]{2,})*(/[[\w-]{2,}]*)*"},
|
||||
"regex": r"(\w{2,}://)*[\w-]{2,}\.[\w-]{2,}"
|
||||
r"(\.[\w-]{2,})*(/[[\w-]{2,}]*)*"},
|
||||
"ip": {
|
||||
"bold": str(True),
|
||||
"italic": str(False),
|
||||
"underline": str(False),
|
||||
"text": [0, 0, 0],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"},
|
||||
"regex": r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"},
|
||||
"port_list": {
|
||||
"bold": str(True),
|
||||
"italic": str(False),
|
||||
"underline": str(False),
|
||||
"text": [0, 1272, 28362],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "PORT\s+STATE\s+SERVICE(\s+VERSION)?[^\n]*"},
|
||||
"regex": r"PORT\s+STATE\s+SERVICE(\s+VERSION)?[^\n]*"},
|
||||
"open_port": {
|
||||
"bold": str(True),
|
||||
"italic": str(False),
|
||||
"underline": str(False),
|
||||
"text": [0, 41036, 2396],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "\d{1,5}/.{1,5}\s+open\s+.*"},
|
||||
"regex": r"\d{1,5}/.{1,5}\s+open\s+.*"},
|
||||
"closed_port": {
|
||||
"bold": str(False),
|
||||
"italic": str(False),
|
||||
"underline": str(False),
|
||||
"text": [65535, 0, 0],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "\d{1,5}/.{1,5}\s+closed\s+.*"},
|
||||
"regex": r"\d{1,5}/.{1,5}\s+closed\s+.*"},
|
||||
"filtered_port": {
|
||||
"bold": str(False),
|
||||
"italic": str(False),
|
||||
"underline": str(False),
|
||||
"text": [38502, 39119, 0],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "\d{1,5}/.{1,5}\s+filtered\s+.*"},
|
||||
"regex": r"\d{1,5}/.{1,5}\s+filtered\s+.*"},
|
||||
"details": {
|
||||
"bold": str(True),
|
||||
"italic": str(False),
|
||||
"underline": str(True),
|
||||
"text": [0, 0, 0],
|
||||
"highlight": [65535, 65535, 65535],
|
||||
"regex": "^(\w{2,}[\s]{,3}){,4}:"}
|
||||
"regex": r"^(\w{2,}[\s]{,3}){,4}:"}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,7 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
from ConfigParser import ConfigParser, DEFAULTSECT, NoOptionError, \
|
||||
from configparser import ConfigParser, DEFAULTSECT, NoOptionError, \
|
||||
NoSectionError
|
||||
from zenmapCore.UmitLogging import log
|
||||
|
||||
@@ -74,7 +73,7 @@ class UmitConfigParser(ConfigParser):
|
||||
if not self.has_section(section):
|
||||
self.add_section(section)
|
||||
|
||||
ConfigParser.set(self, section, option, value)
|
||||
ConfigParser.set(self, section, option, str(value))
|
||||
self.save_changes()
|
||||
|
||||
def read(self, filename):
|
||||
@@ -104,15 +103,13 @@ class UmitConfigParser(ConfigParser):
|
||||
if self._defaults:
|
||||
fp.write("[%s]\n" % DEFAULTSECT)
|
||||
|
||||
items = self._defaults.items()
|
||||
items.sort()
|
||||
items = sorted(self._defaults.items())
|
||||
|
||||
for (key, value) in items:
|
||||
fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
|
||||
fp.write("\n")
|
||||
|
||||
sects = self._sections.keys()
|
||||
sects.sort()
|
||||
sects = sorted(self._sections.keys())
|
||||
|
||||
for section in sects:
|
||||
fp.write("[%s]\n" % section)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,20 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
from hashlib import md5
|
||||
|
||||
sqlite = None
|
||||
try:
|
||||
from pysqlite2 import dbapi2 as sqlite
|
||||
except ImportError:
|
||||
try:
|
||||
# In case this script is been running under python2.5 with sqlite3
|
||||
import sqlite3 as sqlite
|
||||
except ImportError:
|
||||
raise ImportError(_("No module named dbapi2.pysqlite2 or sqlite3"))
|
||||
|
||||
from time import time
|
||||
|
||||
from zenmapCore.Paths import Path
|
||||
@@ -84,7 +73,7 @@ try:
|
||||
umitdb = Path.db
|
||||
except Exception:
|
||||
import os.path
|
||||
from BasePaths import base_paths
|
||||
from .BasePaths import base_paths
|
||||
|
||||
umitdb = os.path.join(Path.user_config_dir, base_paths["db"])
|
||||
Path.db = umitdb
|
||||
@@ -102,28 +91,7 @@ if not exists(umitdb) or \
|
||||
umitdb = ":memory:"
|
||||
using_memory = True
|
||||
|
||||
if isinstance(umitdb, str):
|
||||
fs_enc = sys.getfilesystemencoding()
|
||||
if fs_enc is None:
|
||||
fs_enc = "UTF-8"
|
||||
umitdb = umitdb.decode(fs_enc)
|
||||
|
||||
# pysqlite 2.4.0 doesn't handle a unicode database name, though earlier and
|
||||
# later versions do. Encode to UTF-8 as pysqlite would do internally anyway.
|
||||
umitdb = umitdb.encode("UTF-8")
|
||||
|
||||
connection = sqlite.connect(umitdb)
|
||||
|
||||
# By default pysqlite will raise an OperationalError when trying to return a
|
||||
# TEXT data type that is not UTF-8 (it always tries to decode text in order to
|
||||
# return a unicode object). We store XML in the database, which may have a
|
||||
# different encoding, so instruct pysqlite to return a plain str for TEXT data
|
||||
# types, and not to attempt any decoding.
|
||||
try:
|
||||
connection.text_factory = str
|
||||
except AttributeError:
|
||||
# However, text_factory is available only in pysqlite 2.1.0 and later.
|
||||
pass
|
||||
connection = sqlite3.connect(umitdb)
|
||||
|
||||
|
||||
class Table(object):
|
||||
@@ -170,7 +138,7 @@ class Table(object):
|
||||
sql = sql[:][:-2]
|
||||
sql += ") VALUES ("
|
||||
|
||||
for v in xrange(len(kargs.values())):
|
||||
for v in range(len(kargs.values())):
|
||||
sql += "?, "
|
||||
|
||||
sql = sql[:][:-2]
|
||||
@@ -258,7 +226,7 @@ class Scans(Table, object):
|
||||
raise Exception("Can't save result without xml output")
|
||||
|
||||
if not self.verify_digest(
|
||||
md5(kargs["nmap_xml_output"]).hexdigest()):
|
||||
md5(kargs["nmap_xml_output"].encode("UTF-8")).hexdigest()):
|
||||
raise Exception("XML output registered already!")
|
||||
|
||||
self.scans_id = self.insert(**kargs)
|
||||
@@ -302,7 +270,7 @@ class Scans(Table, object):
|
||||
|
||||
def set_nmap_xml_output(self, nmap_xml_output):
|
||||
self.set_item("nmap_xml_output", nmap_xml_output)
|
||||
self.set_item("digest", md5(nmap_xml_output).hexdigest())
|
||||
self.set_item("digest", md5(nmap_xml_output.encode("UTF-8")).hexdigest())
|
||||
|
||||
def get_date(self):
|
||||
return self.get_item("date")
|
||||
@@ -328,7 +296,7 @@ def verify_db():
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
cursor.execute("SELECT scans_id FROM scans WHERE date = 0")
|
||||
except sqlite.OperationalError:
|
||||
except sqlite3.OperationalError:
|
||||
u = UmitDB()
|
||||
u.create_db()
|
||||
verify_db()
|
||||
@@ -354,5 +322,5 @@ if __name__ == "__main__":
|
||||
|
||||
sql = "SELECT * FROM scans;"
|
||||
u.cursor.execute(sql)
|
||||
print "Scans:",
|
||||
print("Scans:", end=' ')
|
||||
pprint(u.cursor.fetchall())
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import webbrowser
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGDialog
|
||||
@@ -84,7 +87,7 @@ xml.__path__ = [x for x in xml.__path__ if "_xmlplus" not in x]
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
|
||||
class _program_entry(gtk.VBox):
|
||||
class _program_entry(Gtk.Box):
|
||||
"""A little box containing labels with a program's name and
|
||||
description and a clickable link to its web site."""
|
||||
|
||||
@@ -93,34 +96,30 @@ class _program_entry(gtk.VBox):
|
||||
NAME_WEB_SITE_SPACING = 20
|
||||
|
||||
def __init__(self, name=None, web_site=None, description=None):
|
||||
gtk.VBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
self.hbox = gtk.HBox(False, self.NAME_WEB_SITE_SPACING)
|
||||
self.pack_start(self.hbox)
|
||||
self.hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL,
|
||||
self.NAME_WEB_SITE_SPACING)
|
||||
self.pack_start(self.hbox, True, True, 0)
|
||||
|
||||
if name is not None:
|
||||
name_label = gtk.Label()
|
||||
name_label = Gtk.Label()
|
||||
name_label.set_markup(
|
||||
'<span size="large" weight="bold">%s</span>' % escape(
|
||||
name))
|
||||
self.hbox.pack_start(name_label, False)
|
||||
self.hbox.pack_start(name_label, False, True, 0)
|
||||
|
||||
if web_site is not None:
|
||||
try:
|
||||
web_site_button = gtk.LinkButton(web_site)
|
||||
web_site_button = Gtk.LinkButton.new(web_site)
|
||||
web_site_button.connect("clicked", self._link_button_open)
|
||||
except AttributeError:
|
||||
# LinkButton was only introduced in PyGTK 2.10.
|
||||
web_site_button = gtk.Label(web_site)
|
||||
web_site_button.set_selectable(True)
|
||||
self.hbox.pack_start(web_site_button, False)
|
||||
self.hbox.pack_start(web_site_button, False, True, 0)
|
||||
|
||||
if description is not None:
|
||||
description_label = gtk.Label()
|
||||
description_label = Gtk.Label()
|
||||
description_label.set_alignment(0.0, 0.0)
|
||||
description_label.set_line_wrap(True)
|
||||
description_label.set_text(description)
|
||||
self.pack_start(description_label)
|
||||
self.pack_start(description_label, True, True, 0)
|
||||
|
||||
def _link_button_open(self, widget):
|
||||
webbrowser.open(widget.get_uri())
|
||||
@@ -128,7 +127,7 @@ class _program_entry(gtk.VBox):
|
||||
|
||||
class About(HIGDialog):
|
||||
"""An about dialog showing information about the program. It is meant to
|
||||
have roughly the same feel as gtk.AboutDialog."""
|
||||
have roughly the same feel as Gtk.AboutDialog."""
|
||||
def __init__(self):
|
||||
HIGDialog.__init__(self)
|
||||
self.set_title(_("About %s and %s") % (
|
||||
@@ -137,44 +136,43 @@ class About(HIGDialog):
|
||||
self.vbox.set_border_width(12)
|
||||
self.vbox.set_spacing(12)
|
||||
|
||||
label = gtk.Label()
|
||||
label = Gtk.Label()
|
||||
label.set_markup(
|
||||
'<span size="xx-large" weight="bold">%s %s</span>' % (
|
||||
escape(APP_DISPLAY_NAME), escape(VERSION)))
|
||||
label.set_selectable(True)
|
||||
self.vbox.pack_start(label)
|
||||
self.vbox.pack_start(label, True, True, 0)
|
||||
|
||||
label = gtk.Label()
|
||||
label = Gtk.Label()
|
||||
label.set_markup(
|
||||
'<span size="small">%s</span>' % (escape(APP_COPYRIGHT)))
|
||||
self.vbox.pack_start(label)
|
||||
self.vbox.pack_start(label, True, True, 0)
|
||||
|
||||
entry = _program_entry(NMAP_DISPLAY_NAME, NMAP_WEB_SITE, _(
|
||||
"%s is a free and open source utility for network exploration "
|
||||
"and security auditing.") % NMAP_DISPLAY_NAME)
|
||||
self.vbox.pack_start(entry)
|
||||
self.vbox.pack_start(entry, True, True, 0)
|
||||
|
||||
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))
|
||||
self.vbox.pack_start(entry)
|
||||
self.vbox.pack_start(entry, True, True, 0)
|
||||
|
||||
entry = _program_entry(UMIT_DISPLAY_NAME, UMIT_WEB_SITE, _(
|
||||
"%s is an %s GUI created as part of the Nmap/Google Summer "
|
||||
"of Code program.") % (UMIT_DISPLAY_NAME, NMAP_DISPLAY_NAME))
|
||||
button = gtk.Button(_("%s credits") % UMIT_DISPLAY_NAME)
|
||||
button = Gtk.Button.new_with_label(_("%s credits") % UMIT_DISPLAY_NAME)
|
||||
button.connect("clicked", self._show_umit_credits)
|
||||
entry.hbox.pack_start(button, False)
|
||||
self.vbox.pack_start(entry)
|
||||
entry.hbox.pack_start(button, False, True, 0)
|
||||
self.vbox.pack_start(entry, True, True, 0)
|
||||
|
||||
self.vbox.show_all()
|
||||
|
||||
close_button = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL)
|
||||
self.set_default_response(gtk.RESPONSE_CANCEL)
|
||||
close_button = self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL)
|
||||
self.set_default_response(Gtk.ResponseType.CANCEL)
|
||||
close_button.grab_focus()
|
||||
|
||||
self.set_has_separator(False)
|
||||
self.set_resizable(False)
|
||||
|
||||
self._umit_credits_dialog = None
|
||||
@@ -208,7 +206,7 @@ class UmitCredits(HIGWindow):
|
||||
HIGWindow.__init__(self)
|
||||
self.set_title(_("%s credits") % UMIT_DISPLAY_NAME)
|
||||
self.set_size_request(-1, 250)
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
self.__create_widgets()
|
||||
self.__packing()
|
||||
@@ -218,7 +216,7 @@ class UmitCredits(HIGWindow):
|
||||
self.vbox = HIGVBox()
|
||||
self.hbox = HIGHBox()
|
||||
self.notebook = HIGNotebook()
|
||||
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
|
||||
self.btn_close = HIGButton(stock=Gtk.STOCK_CLOSE)
|
||||
|
||||
self.written_by_scroll = HIGScrolledWindow()
|
||||
self.written_by_text = HIGTextView()
|
||||
@@ -248,35 +246,35 @@ class UmitCredits(HIGWindow):
|
||||
self.hbox._pack_noexpand_nofill(self.btn_close)
|
||||
|
||||
self.notebook.append_page(
|
||||
self.written_by_scroll, gtk.Label(_("Written by")))
|
||||
self.written_by_scroll, Gtk.Label.new(_("Written by")))
|
||||
self.notebook.append_page(
|
||||
self.design_scroll, gtk.Label(_("Design")))
|
||||
self.design_scroll, Gtk.Label.new(_("Design")))
|
||||
self.notebook.append_page(
|
||||
self.soc2007_scroll, gtk.Label(_("SoC 2007")))
|
||||
self.soc2007_scroll, Gtk.Label.new(_("SoC 2007")))
|
||||
self.notebook.append_page(
|
||||
self.contributors_scroll, gtk.Label(_("Contributors")))
|
||||
self.contributors_scroll, Gtk.Label.new(_("Contributors")))
|
||||
self.notebook.append_page(
|
||||
self.translation_scroll, gtk.Label(_("Translation")))
|
||||
self.translation_scroll, Gtk.Label.new(_("Translation")))
|
||||
self.notebook.append_page(
|
||||
self.nokia_scroll, gtk.Label(_("Maemo")))
|
||||
self.nokia_scroll, Gtk.Label.new(_("Maemo")))
|
||||
|
||||
self.written_by_scroll.add(self.written_by_text)
|
||||
self.written_by_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.written_by_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.design_scroll.add(self.design_text)
|
||||
self.design_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.design_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.soc2007_scroll.add(self.soc2007_text)
|
||||
self.soc2007_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.soc2007_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.contributors_scroll.add(self.contributors_text)
|
||||
self.contributors_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.contributors_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.translation_scroll.add(self.translation_text)
|
||||
self.translation_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.translation_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.nokia_scroll.add(self.nokia_text)
|
||||
self.nokia_text.set_wrap_mode(gtk.WRAP_NONE)
|
||||
self.nokia_text.set_wrap_mode(Gtk.WrapMode.NONE)
|
||||
|
||||
self.btn_close.connect('clicked', lambda x, y=None: self.destroy())
|
||||
|
||||
@@ -365,6 +363,6 @@ Adriano Monteiro Marques <py.adriano@gmail.com>""")
|
||||
if __name__ == '__main__':
|
||||
about = About()
|
||||
about.show()
|
||||
about.connect("response", lambda widget, response: gtk.main_quit())
|
||||
about.connect("response", lambda widget, response: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -62,7 +61,7 @@ import imp
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import ConfigParser
|
||||
import configparser
|
||||
import shutil
|
||||
|
||||
# Cause an exception if PyGTK can't open a display. Normally this just
|
||||
@@ -74,7 +73,9 @@ import shutil
|
||||
import warnings
|
||||
warnings.filterwarnings("error", module="gtk", append="True")
|
||||
try:
|
||||
import gtk
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
except Exception:
|
||||
# On Mac OS X 10.5, X11 is supposed to be automatically launched on demand.
|
||||
# It works by setting the DISPLAY environment variable to something like
|
||||
@@ -86,7 +87,9 @@ except Exception:
|
||||
# startup scripts, and for some reason the first connection (the one that
|
||||
# caused the launch) is rejected. But somehow subsequent connections work
|
||||
# fine! So if the import fails, try one more time.
|
||||
import gtk
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
warnings.resetwarnings()
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
|
||||
@@ -103,17 +106,17 @@ from zenmapCore.Name import APP_DISPLAY_NAME
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
|
||||
|
||||
# A global list of open scan windows. When the last one is destroyed, we call
|
||||
# gtk.main_quit.
|
||||
# Gtk.main_quit.
|
||||
open_windows = []
|
||||
|
||||
|
||||
def _destroy_callback(window):
|
||||
open_windows.remove(window)
|
||||
if len(open_windows) == 0:
|
||||
gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
try:
|
||||
from zenmapCore.UmitDB import UmitDB
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
log.debug(">>> Not cleaning up database: %s." % str(e))
|
||||
else:
|
||||
# Cleaning up data base
|
||||
@@ -160,29 +163,31 @@ def install_excepthook():
|
||||
# produces a warning, but the lack of a display eventually causes a
|
||||
# segmentation fault. See http://live.gnome.org/PyGTK/WhatsNew210.
|
||||
warnings.filterwarnings("error", module="gtk")
|
||||
import gtk
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
warnings.resetwarnings()
|
||||
|
||||
gtk.gdk.threads_enter()
|
||||
Gdk.threads_enter()
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
|
||||
from zenmapGUI.CrashReport import CrashReport
|
||||
if type == ImportError:
|
||||
d = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
|
||||
d = HIGAlertDialog(type=Gtk.MessageType.ERROR,
|
||||
message_format=_("Import error"),
|
||||
secondary_text=_("""A required module was not found.
|
||||
|
||||
""" + unicode(value)))
|
||||
""" + str(value)))
|
||||
d.run()
|
||||
d.destroy()
|
||||
else:
|
||||
c = CrashReport(type, value, tb)
|
||||
c.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
gtk.gdk.threads_leave()
|
||||
Gdk.threads_leave()
|
||||
|
||||
gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
|
||||
sys.excepthook = excepthook
|
||||
|
||||
@@ -215,7 +220,7 @@ def run():
|
||||
# template directory.
|
||||
create_user_config_dir(
|
||||
Path.user_config_dir, Path.config_dir)
|
||||
except (IOError, OSError), e:
|
||||
except (IOError, OSError) as e:
|
||||
error_dialog = HIGAlertDialog(
|
||||
message_format=_(
|
||||
"Error creating the per-user configuration directory"),
|
||||
@@ -239,7 +244,7 @@ scan profiles. Check for access to the directory and try again.""") % (
|
||||
try:
|
||||
# Read the ~/.zenmap/zenmap.conf configuration file.
|
||||
zenmapCore.UmitConf.config_parser.read(Path.user_config_file)
|
||||
except ConfigParser.ParsingError, e:
|
||||
except configparser.ParsingError as e:
|
||||
# ParsingError can leave some values as lists instead of strings. Just
|
||||
# blow it all away if we have this problem.
|
||||
zenmapCore.UmitConf.config_parser = zenmapCore.UmitConf.config_parser.__class__()
|
||||
@@ -258,7 +263,7 @@ until it is repaired.""") % (Path.user_config_file, str(e), APP_DISPLAY_NAME)
|
||||
error_dialog.destroy()
|
||||
global_config_path = os.path.join(Path.config_dir, APP_NAME + '.conf')
|
||||
repair_dialog = HIGAlertDialog(
|
||||
type=gtk.MESSAGE_QUESTION,
|
||||
type=Gtk.MessageType.QUESTION,
|
||||
message_format=_("Restore default configuration?"),
|
||||
secondary_text=_("""\
|
||||
To avoid further errors parsing the configuration file %s, \
|
||||
@@ -267,9 +272,9 @@ you can copy the default configuration from %s.
|
||||
Do this now? \
|
||||
""") % (Path.user_config_file, global_config_path),
|
||||
)
|
||||
repair_dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
|
||||
repair_dialog.set_default_response(gtk.RESPONSE_CANCEL)
|
||||
if repair_dialog.run() == gtk.RESPONSE_OK:
|
||||
repair_dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
|
||||
repair_dialog.set_default_response(Gtk.ResponseType.CANCEL)
|
||||
if repair_dialog.run() == Gtk.ResponseType.OK:
|
||||
shutil.copyfile(global_config_path, Path.user_config_file)
|
||||
log.debug(">>> Copy %s to %s." % (global_config_path, Path.user_config_file))
|
||||
repair_dialog.destroy()
|
||||
@@ -316,13 +321,13 @@ Do this now? \
|
||||
|
||||
if main_is_frozen():
|
||||
# This is needed by py2exe
|
||||
gtk.gdk.threads_init()
|
||||
gtk.gdk.threads_enter()
|
||||
Gdk.threads_init()
|
||||
Gdk.threads_enter()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
if main_is_frozen():
|
||||
gtk.gdk.threads_leave()
|
||||
Gdk.threads_leave()
|
||||
|
||||
|
||||
class NonRootWarning (HIGAlertDialog):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
|
||||
@@ -74,11 +76,12 @@ xml.__path__ = [x for x in xml.__path__ if "_xmlplus" not in x]
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
|
||||
class BugReport(gtk.Window, object):
|
||||
class BugReport(Gtk.Window, object):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_('How to Report a Bug'))
|
||||
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
||||
self.set_resizable(False)
|
||||
|
||||
self._create_widgets()
|
||||
self._pack_widgets()
|
||||
@@ -86,16 +89,17 @@ class BugReport(gtk.Window, object):
|
||||
|
||||
def _create_widgets(self):
|
||||
self.vbox = HIGVBox()
|
||||
self.button_box = gtk.HButtonBox()
|
||||
self.button_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.text = gtk.Label()
|
||||
self.text = Gtk.Label()
|
||||
|
||||
self.btn_ok = gtk.Button(stock=gtk.STOCK_OK)
|
||||
self.btn_ok = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.vbox.set_border_width(6)
|
||||
|
||||
self.text.set_line_wrap(True)
|
||||
self.text.set_max_width_chars(50)
|
||||
self.text.set_markup(_("""\
|
||||
<big><b>How to report a bug</b></big>
|
||||
|
||||
@@ -124,8 +128,8 @@ https://nmap.org/data/HACKING. Patches may be sent to nmap-dev \
|
||||
})
|
||||
self.vbox.add(self.text)
|
||||
|
||||
self.button_box.set_layout(gtk.BUTTONBOX_END)
|
||||
self.button_box.pack_start(self.btn_ok)
|
||||
self.button_box.set_layout(Gtk.ButtonBoxStyle.END)
|
||||
self.button_box.pack_start(self.btn_ok, True, True, 0)
|
||||
|
||||
self.vbox._pack_noexpand_nofill(self.button_box)
|
||||
self.add(self.vbox)
|
||||
@@ -140,6 +144,6 @@ https://nmap.org/data/HACKING. Patches may be sent to nmap-dev \
|
||||
if __name__ == "__main__":
|
||||
w = BugReport()
|
||||
w.show_all()
|
||||
w.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
import sys
|
||||
import gtk
|
||||
import traceback
|
||||
|
||||
from zenmapGUI.higwidgets.higdialogs import HIGDialog
|
||||
@@ -81,9 +84,9 @@ from xml.sax.saxutils import escape
|
||||
class CrashReport(HIGDialog):
|
||||
def __init__(self, type, value, tb):
|
||||
HIGDialog.__init__(self)
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_('Crash Report'))
|
||||
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
|
||||
|
||||
self._create_widgets()
|
||||
self._pack_widgets()
|
||||
@@ -94,58 +97,59 @@ class CrashReport(HIGDialog):
|
||||
self.description_text.get_buffer().set_text(text)
|
||||
|
||||
def _create_widgets(self):
|
||||
self.button_box = gtk.HButtonBox()
|
||||
self.button_box_ok = gtk.HButtonBox()
|
||||
self.button_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
self.button_box_ok = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.description_scrolled = gtk.ScrolledWindow()
|
||||
self.description_text = gtk.TextView()
|
||||
self.description_scrolled = Gtk.ScrolledWindow()
|
||||
self.description_text = Gtk.TextView()
|
||||
self.description_text.set_editable(False)
|
||||
|
||||
self.bug_text = gtk.Label()
|
||||
self.bug_text = Gtk.Label()
|
||||
self.bug_text.set_markup(_('An unexpected error has crashed '
|
||||
'%(app_name)s. Please copy the stack trace below and send it to '
|
||||
'the <a href="mailto:dev@nmap.org">dev@nmap.org</a> mailing list. '
|
||||
'(<a href="http://seclists.org/nmap-dev/">More about the list.</a>'
|
||||
') The developers will see your report and try to fix the problem.'
|
||||
) % {"app_name": escape(APP_DISPLAY_NAME)})
|
||||
self.email_frame = gtk.Frame()
|
||||
self.email_label = gtk.Label()
|
||||
self.email_frame = Gtk.Frame()
|
||||
self.email_label = Gtk.Label()
|
||||
self.email_label.set_markup(_('<b>Copy and email to '
|
||||
'<a href="mailto:dev@nmap.org">dev@nmap.org</a>:</b>'))
|
||||
self.btn_copy = gtk.Button(stock=gtk.STOCK_COPY)
|
||||
self.btn_ok = gtk.Button(stock=gtk.STOCK_OK)
|
||||
self.btn_copy = Gtk.Button.new_from_stock(Gtk.STOCK_COPY)
|
||||
self.btn_ok = Gtk.Button.new_from_stock(Gtk.STOCK_OK)
|
||||
|
||||
self.hbox = HIGHBox()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.description_scrolled.add(self.description_text)
|
||||
self.description_scrolled.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.description_scrolled.set_size_request(400, 150)
|
||||
self.description_text.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.description_text.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
|
||||
self.bug_text.set_max_width_chars(60)
|
||||
self.bug_text.set_line_wrap(True)
|
||||
self.email_label.set_line_wrap(True)
|
||||
|
||||
self.email_frame.set_label_widget(self.email_label)
|
||||
self.email_frame.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self.email_frame.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
|
||||
self.hbox.set_border_width(6)
|
||||
self.vbox.set_border_width(6)
|
||||
|
||||
self.hbox._pack_expand_fill(self.bug_text)
|
||||
|
||||
self.button_box.set_layout(gtk.BUTTONBOX_START)
|
||||
self.button_box_ok.set_layout(gtk.BUTTONBOX_END)
|
||||
self.button_box.set_layout(Gtk.ButtonBoxStyle.START)
|
||||
self.button_box_ok.set_layout(Gtk.ButtonBoxStyle.END)
|
||||
|
||||
self.button_box.pack_start(self.btn_copy)
|
||||
self.button_box_ok.pack_start(self.btn_ok)
|
||||
self.button_box.pack_start(self.btn_copy, True, True, 0)
|
||||
self.button_box_ok.pack_start(self.btn_ok, True, True, 0)
|
||||
|
||||
self.vbox.pack_start(self.hbox)
|
||||
self.vbox.pack_start(self.email_frame)
|
||||
self.vbox.pack_start(self.description_scrolled)
|
||||
self.vbox.pack_start(self.button_box)
|
||||
self.action_area.pack_start(self.button_box_ok)
|
||||
self.vbox.pack_start(self.hbox, True, True, 0)
|
||||
self.vbox.pack_start(self.email_frame, True, True, 0)
|
||||
self.vbox.pack_start(self.description_scrolled, True, True, 0)
|
||||
self.vbox.pack_start(self.button_box, True, True, 0)
|
||||
self.action_area.pack_start(self.button_box_ok, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.btn_ok.connect("clicked", self.close)
|
||||
@@ -154,21 +158,21 @@ class CrashReport(HIGDialog):
|
||||
|
||||
def get_description(self):
|
||||
buff = self.description_text.get_buffer()
|
||||
return buff.get_text(buff.get_start_iter(), buff.get_end_iter())
|
||||
return buff.get_text(buff.get_start_iter(), buff.get_end_iter(), include_hidden_chars=True)
|
||||
|
||||
def copy(self, widget=None, event=None):
|
||||
clipboard = gtk.clipboard_get()
|
||||
clipboard.set_text(self.get_description())
|
||||
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||
clipboard.set_text(self.get_description(), -1)
|
||||
clipboard.store()
|
||||
|
||||
def close(self, widget=None, event=None):
|
||||
self.destroy()
|
||||
gtk.main_quit()
|
||||
Gtk.main_quit()
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
c = CrashReport(None, None, None)
|
||||
c.show_all()
|
||||
c.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
c.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject, GLib
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
@@ -94,11 +96,12 @@ class ScanChooser(HIGVBox):
|
||||
has changed."""
|
||||
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, scans, title):
|
||||
self.__gobject_init__()
|
||||
HIGVBox.__init__(self)
|
||||
|
||||
self.title = title
|
||||
self.scan_dict = {}
|
||||
|
||||
@@ -126,13 +129,12 @@ class ScanChooser(HIGVBox):
|
||||
self.lbl_scan = HIGSectionLabel(self.title)
|
||||
self.hbox = HIGHBox()
|
||||
self.table = HIGTable()
|
||||
self.list_scan = gtk.ListStore(str)
|
||||
self.combo_scan = gtk.ComboBoxEntry(self.list_scan, 0)
|
||||
self.btn_open_scan = gtk.Button(stock=gtk.STOCK_OPEN)
|
||||
self.exp_scan = gtk.Expander(_("Scan Output"))
|
||||
self.scrolled = gtk.ScrolledWindow()
|
||||
self.txt_scan_result = gtk.TextView()
|
||||
self.txg_tag = gtk.TextTag("scan_style")
|
||||
self.combo_scan = Gtk.ComboBoxText.new_with_entry()
|
||||
self.btn_open_scan = Gtk.Button.new_from_stock(Gtk.STOCK_OPEN)
|
||||
self.exp_scan = Gtk.Expander.new(_("Scan Output"))
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
self.txt_scan_result = Gtk.TextView()
|
||||
self.txg_tag = Gtk.TextTag.new("scan_style")
|
||||
|
||||
def get_buffer(self):
|
||||
return self.txt_scan_result.get_buffer()
|
||||
@@ -166,14 +168,14 @@ class ScanChooser(HIGVBox):
|
||||
self.scrolled.add_with_viewport(self.txt_scan_result)
|
||||
|
||||
# Setting scrolled window
|
||||
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def _set_text_view(self):
|
||||
self.txg_table = self.txt_scan_result.get_buffer().get_tag_table()
|
||||
self.txg_table.add(self.txg_tag)
|
||||
self.txg_tag.set_property("family", "Monospace")
|
||||
|
||||
self.txt_scan_result.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.txt_scan_result.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.txt_scan_result.set_editable(False)
|
||||
self.txt_scan_result.get_buffer().connect(
|
||||
"changed", self._text_changed_cb)
|
||||
@@ -187,7 +189,7 @@ class ScanChooser(HIGVBox):
|
||||
response = file_chooser.run()
|
||||
file_chosen = file_chooser.get_filename()
|
||||
file_chooser.destroy()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
if response == Gtk.ResponseType.OK:
|
||||
try:
|
||||
parser = NmapParser()
|
||||
parser.parse_file(file_chosen)
|
||||
@@ -214,7 +216,7 @@ class ScanChooser(HIGVBox):
|
||||
scan_name = os.path.split(file_chosen)[-1]
|
||||
self.add_scan(scan_name, parser)
|
||||
|
||||
self.combo_scan.set_active(len(self.list_scan) - 1)
|
||||
self.combo_scan.set_active(len(self.combo_scan.get_model()) - 1)
|
||||
|
||||
def add_scan(self, scan_name, parser):
|
||||
scan_id = 1
|
||||
@@ -223,7 +225,7 @@ class ScanChooser(HIGVBox):
|
||||
new_scan_name = "%s (%s)" % (scan_name, scan_id)
|
||||
scan_id += 1
|
||||
|
||||
self.list_scan.append([new_scan_name])
|
||||
self.combo_scan.append_text(new_scan_name)
|
||||
self.scan_dict[new_scan_name] = parser
|
||||
|
||||
def _text_changed_cb(self, widget):
|
||||
@@ -234,7 +236,7 @@ class ScanChooser(HIGVBox):
|
||||
def get_parsed_scan(self):
|
||||
"""Return the currently selected scan's parsed output as an NmapParser
|
||||
object, or None if no valid scan is selected."""
|
||||
selected_scan = self.combo_scan.child.get_text()
|
||||
selected_scan = self.combo_scan.get_active_text()
|
||||
return self.scan_dict.get(selected_scan)
|
||||
|
||||
def get_nmap_output(self):
|
||||
@@ -249,9 +251,9 @@ class ScanChooser(HIGVBox):
|
||||
parsed_scan = property(get_parsed_scan)
|
||||
|
||||
|
||||
class DiffWindow(gtk.Window):
|
||||
class DiffWindow(Gtk.Window):
|
||||
def __init__(self, scans):
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_("Compare Results"))
|
||||
self.ndiff_process = None
|
||||
# We allow the user to start a new diff before the old one has
|
||||
@@ -265,11 +267,11 @@ class DiffWindow(gtk.Window):
|
||||
self.diff_view = DiffView()
|
||||
self.diff_view.set_size_request(-1, 100)
|
||||
self.hbox_buttons = HIGHBox()
|
||||
self.progress = gtk.ProgressBar()
|
||||
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
|
||||
self.progress = Gtk.ProgressBar()
|
||||
self.btn_close = HIGButton(stock=Gtk.STOCK_CLOSE)
|
||||
self.hbox_selection = HIGHBox()
|
||||
self.scan_chooser_a = ScanChooser(scans, _(u"A Scan"))
|
||||
self.scan_chooser_b = ScanChooser(scans, _(u"B Scan"))
|
||||
self.scan_chooser_a = ScanChooser(scans, _("A Scan"))
|
||||
self.scan_chooser_b = ScanChooser(scans, _("B Scan"))
|
||||
|
||||
self._pack_widgets()
|
||||
self._connect_widgets()
|
||||
@@ -282,20 +284,20 @@ class DiffWindow(gtk.Window):
|
||||
def _pack_widgets(self):
|
||||
self.main_vbox.set_border_width(6)
|
||||
|
||||
self.hbox_selection.pack_start(self.scan_chooser_a, True, True)
|
||||
self.hbox_selection.pack_start(self.scan_chooser_b, True, True)
|
||||
self.hbox_selection.pack_start(self.scan_chooser_a, True, True, 0)
|
||||
self.hbox_selection.pack_start(self.scan_chooser_b, True, True, 0)
|
||||
|
||||
self.main_vbox.pack_start(self.hbox_selection, False)
|
||||
self.main_vbox.pack_start(self.hbox_selection, False, True, 0)
|
||||
|
||||
scroll = gtk.ScrolledWindow()
|
||||
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add(self.diff_view)
|
||||
self.main_vbox.pack_start(scroll, True, True)
|
||||
self.main_vbox.pack_start(scroll, True, True, 0)
|
||||
|
||||
self.progress.hide()
|
||||
self.progress.set_no_show_all(True)
|
||||
self.hbox_buttons.pack_start(self.progress, False)
|
||||
self.hbox_buttons.pack_end(self.btn_close, False)
|
||||
self.hbox_buttons.pack_start(self.progress, False, True, 0)
|
||||
self.hbox_buttons.pack_end(self.btn_close, False, True, 0)
|
||||
|
||||
self.main_vbox._pack_noexpand_nofill(self.hbox_buttons)
|
||||
|
||||
@@ -337,7 +339,7 @@ class DiffWindow(gtk.Window):
|
||||
else:
|
||||
self.progress.show()
|
||||
if self.timer_id is None:
|
||||
self.timer_id = gobject.timeout_add(
|
||||
self.timer_id = GLib.timeout_add(
|
||||
NDIFF_CHECK_TIMEOUT, self.check_ndiff_process)
|
||||
|
||||
def check_ndiff_process(self):
|
||||
@@ -362,7 +364,7 @@ class DiffWindow(gtk.Window):
|
||||
if status == 0 or status == 1:
|
||||
# Successful completion.
|
||||
try:
|
||||
diff = self.ndiff_process.get_scan_diff()
|
||||
diff = self.ndiff_process.get_scan_diff().decode("utf-8")
|
||||
except zenmapCore.Diff.NdiffParseException as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Error parsing ndiff output"),
|
||||
@@ -401,13 +403,13 @@ class DiffWindow(gtk.Window):
|
||||
self.destroy()
|
||||
|
||||
|
||||
class DiffView(gtk.TextView):
|
||||
class DiffView(Gtk.TextView):
|
||||
REMOVE_COLOR = "#ffaaaa"
|
||||
ADD_COLOR = "#ccffcc"
|
||||
|
||||
"""A widget displaying a zenmapCore.Diff.ScanDiff."""
|
||||
def __init__(self):
|
||||
gtk.TextView.__init__(self)
|
||||
Gtk.TextView.__init__(self)
|
||||
self.set_editable(False)
|
||||
|
||||
buff = self.get_buffer()
|
||||
@@ -418,7 +420,7 @@ class DiffView(gtk.TextView):
|
||||
buff.create_tag("+", font="Monospace", background=self.ADD_COLOR)
|
||||
|
||||
def clear(self):
|
||||
self.get_buffer().set_text(u"")
|
||||
self.get_buffer().set_text("")
|
||||
|
||||
def show_diff(self, diff):
|
||||
self.clear()
|
||||
@@ -451,6 +453,6 @@ if __name__ == "__main__":
|
||||
"Parsed 4": parsed4})
|
||||
|
||||
dw.show_all()
|
||||
dw.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
dw.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,27 +57,31 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
import gtk
|
||||
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
RESPONSE_OPEN_DIRECTORY = 1
|
||||
|
||||
|
||||
class AllFilesFileFilter(gtk.FileFilter):
|
||||
class AllFilesFileFilter(Gtk.FileFilter):
|
||||
def __init__(self):
|
||||
gtk.FileFilter.__init__(self)
|
||||
Gtk.FileFilter.__init__(self)
|
||||
|
||||
pattern = "*"
|
||||
self.add_pattern(pattern)
|
||||
self.set_name(_("All files (%s)") % pattern)
|
||||
|
||||
|
||||
class ResultsFileFilter(gtk.FileFilter):
|
||||
class ResultsFileFilter(Gtk.FileFilter):
|
||||
def __init__(self):
|
||||
gtk.FileFilter.__init__(self)
|
||||
Gtk.FileFilter.__init__(self)
|
||||
|
||||
patterns = ["*.xml"]
|
||||
for pattern in patterns:
|
||||
@@ -86,9 +89,9 @@ class ResultsFileFilter(gtk.FileFilter):
|
||||
self.set_name(_("Nmap XML files (%s)") % ", ".join(patterns))
|
||||
|
||||
|
||||
class ScriptFileFilter(gtk.FileFilter):
|
||||
class ScriptFileFilter(Gtk.FileFilter):
|
||||
def __init__(self):
|
||||
gtk.FileFilter.__init__(self)
|
||||
Gtk.FileFilter.__init__(self)
|
||||
|
||||
patterns = ["*.nse"]
|
||||
for pattern in patterns:
|
||||
@@ -96,7 +99,7 @@ class ScriptFileFilter(gtk.FileFilter):
|
||||
self.set_name(_("NSE scripts (%s)") % ", ".join(patterns))
|
||||
|
||||
|
||||
class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
class UnicodeFileChooserDialog(Gtk.FileChooserDialog):
|
||||
"""This is a base class for file choosers. It is designed to ease the
|
||||
retrieval of Unicode file names. On most platforms, the file names returned
|
||||
are encoded in the encoding given by sys.getfilesystemencoding(). On
|
||||
@@ -104,7 +107,7 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
results in a file not found error. The get_filename method of this class
|
||||
handles the decoding automatically."""
|
||||
def get_filename(self):
|
||||
filename = gtk.FileChooserDialog.get_filename(self)
|
||||
filename = Gtk.FileChooserDialog.get_filename(self)
|
||||
if sys.platform == "win32":
|
||||
encoding = "UTF-8"
|
||||
else:
|
||||
@@ -118,13 +121,13 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog):
|
||||
|
||||
class AllFilesFileChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
gtk.FileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
self.add_filter(AllFilesFileFilter())
|
||||
|
||||
|
||||
@@ -132,40 +135,40 @@ class ResultsFileSingleChooserDialog(UnicodeFileChooserDialog):
|
||||
"""This results file choose only allows the selection of single files, not
|
||||
directories."""
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
for f in (ResultsFileFilter(), AllFilesFileFilter()):
|
||||
self.add_filter(f)
|
||||
|
||||
|
||||
class ResultsFileChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
"Open Directory", RESPONSE_OPEN_DIRECTORY,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
for f in (ResultsFileFilter(), AllFilesFileFilter()):
|
||||
self.add_filter(f)
|
||||
|
||||
|
||||
class ScriptFileChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.OPEN,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent,
|
||||
action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
self.set_select_multiple(True)
|
||||
for f in (ScriptFileFilter(), AllFilesFileFilter()):
|
||||
self.add_filter(f)
|
||||
@@ -185,32 +188,33 @@ class SaveResultsFileChooserDialog(UnicodeFileChooserDialog):
|
||||
}
|
||||
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.SAVE,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent, action, buttons)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
|
||||
types_store = gtk.ListStore(str, str, str)
|
||||
types_store = Gtk.ListStore.new([str, str, str])
|
||||
for type in self.TYPES:
|
||||
types_store.append(type)
|
||||
|
||||
self.combo = gtk.ComboBox(types_store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.combo = Gtk.ComboBox.new_with_model(types_store)
|
||||
cell = Gtk.CellRendererText()
|
||||
self.combo.pack_start(cell, True)
|
||||
self.combo.add_attribute(cell, "text", 0)
|
||||
self.combo.connect("changed", self.combo_changed_cb)
|
||||
self.combo.set_active(1)
|
||||
|
||||
hbox = gtk.HBox(False, 6)
|
||||
hbox.pack_end(self.combo, False)
|
||||
hbox.pack_end(gtk.Label(_("Select File Type:")), False)
|
||||
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
|
||||
hbox.pack_end(self.combo, False, True, 0)
|
||||
hbox.pack_end(Gtk.Label.new(_("Select File Type:")), False, True, 0)
|
||||
hbox.show_all()
|
||||
|
||||
self.set_extra_widget(hbox)
|
||||
self.set_do_overwrite_confirmation(True)
|
||||
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
def combo_changed_cb(self, combo):
|
||||
filename = self.get_filename() or ""
|
||||
@@ -243,19 +247,21 @@ class SaveResultsFileChooserDialog(UnicodeFileChooserDialog):
|
||||
|
||||
class DirectoryChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.SELECT_FOLDER,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OPEN, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent, action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
|
||||
class SaveToDirectoryChooserDialog(UnicodeFileChooserDialog):
|
||||
def __init__(self, title="", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK), backend=None):
|
||||
action=Gtk.FileChooserAction.SELECT_FOLDER,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK), backend=None):
|
||||
|
||||
UnicodeFileChooserDialog.__init__(self, title, parent, action, buttons)
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
UnicodeFileChooserDialog.__init__(self, title=title, parent=parent,
|
||||
action=action, buttons=buttons)
|
||||
self.set_default_response(Gtk.ResponseType.OK)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox
|
||||
from zenmapGUI.higwidgets.higlabels import HintWindow
|
||||
@@ -10,30 +12,30 @@ class FilterBar(HIGHBox):
|
||||
entering a string that restricts the set of visible hosts."""
|
||||
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
HIGHBox.__init__(self)
|
||||
self.information_label = gtk.Label()
|
||||
self.entry = gtk.Entry()
|
||||
self.information_label = Gtk.Label()
|
||||
self.entry = Gtk.Entry()
|
||||
|
||||
self.pack_start(self.information_label, False)
|
||||
self.pack_start(self.information_label, False, True, 0)
|
||||
self.information_label.show()
|
||||
|
||||
label = gtk.Label(_("Host Filter:"))
|
||||
self.pack_start(label, False)
|
||||
label = Gtk.Label.new(_("Host Filter:"))
|
||||
self.pack_start(label, False, True, 0)
|
||||
label.show()
|
||||
|
||||
self.pack_start(self.entry, True, True)
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
self.entry.show()
|
||||
|
||||
help_button = gtk.Button()
|
||||
icon = gtk.Image()
|
||||
icon.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
|
||||
help_button = Gtk.Button()
|
||||
icon = Gtk.Image()
|
||||
icon.set_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.BUTTON)
|
||||
help_button.add(icon)
|
||||
help_button.connect("clicked", self._help_button_clicked)
|
||||
self.pack_start(help_button, False)
|
||||
self.pack_start(help_button, False, True, 0)
|
||||
help_button.show_all()
|
||||
|
||||
self.entry.connect("changed", lambda x: self.emit("changed"))
|
||||
@@ -42,7 +44,7 @@ class FilterBar(HIGHBox):
|
||||
self.entry.grab_focus()
|
||||
|
||||
def get_filter_string(self):
|
||||
return self.entry.get_text().decode("UTF-8")
|
||||
return self.entry.get_text()
|
||||
|
||||
def set_filter_string(self, filter_string):
|
||||
return self.entry.set_text(filter_string)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, GdkPixbuf
|
||||
|
||||
import re
|
||||
import os.path
|
||||
|
||||
@@ -93,7 +95,7 @@ if pixmap_path:
|
||||
def get_pixmap_file_names(icon_name, size):
|
||||
yield '%s_%s.png' % (icon_name, size)
|
||||
|
||||
iconfactory = gtk.IconFactory()
|
||||
iconfactory = Gtk.IconFactory()
|
||||
for icon_name in icon_names:
|
||||
for type, size in (('icon', '32'), ('logo', '75')):
|
||||
key = '%s_%s' % (icon_name, type)
|
||||
@@ -101,9 +103,9 @@ if pixmap_path:
|
||||
for file_name in get_pixmap_file_names(icon_name, size):
|
||||
file_path = os.path.join(pixmap_path, file_name)
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(file_path)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(file_path)
|
||||
break
|
||||
except gobject.GError:
|
||||
except GLib.GError:
|
||||
# Try again.
|
||||
pass
|
||||
else:
|
||||
@@ -113,7 +115,7 @@ if pixmap_path:
|
||||
', '.join(get_pixmap_file_names(icon_name, size)),
|
||||
pixmap_path))
|
||||
continue
|
||||
iconset = gtk.IconSet(pixbuf)
|
||||
iconset = Gtk.IconSet(pixbuf=pixbuf)
|
||||
iconfactory.add(key, iconset)
|
||||
log.debug('Register %s icon name for file %s' % (key, file_path))
|
||||
iconfactory.add_default()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import sys
|
||||
import os
|
||||
@@ -87,7 +89,6 @@ from zenmapGUI.SearchWindow import SearchWindow
|
||||
from zenmapGUI.BugReport import BugReport
|
||||
|
||||
from zenmapCore.Name import APP_DISPLAY_NAME, APP_DOCUMENTATION_SITE
|
||||
from zenmapCore.BasePaths import fs_enc
|
||||
from zenmapCore.Paths import Path
|
||||
from zenmapCore.RecentScans import recent_scans
|
||||
from zenmapCore.UmitLogging import log
|
||||
@@ -106,22 +107,21 @@ if is_maemo():
|
||||
hildon.Window.__init__(self)
|
||||
self.set_resizable(False)
|
||||
self.set_border_width(0)
|
||||
self.vbox = gtk.VBox()
|
||||
self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
self.vbox.set_border_width(0)
|
||||
self.vbox.set_spacing(0)
|
||||
|
||||
else:
|
||||
class UmitScanWindow(HIGMainWindow):
|
||||
def __init__(self):
|
||||
HIGMainWindow.__init__(self)
|
||||
self.vbox = gtk.VBox()
|
||||
self.vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
|
||||
def can_print():
|
||||
"""Return true if we have printing operations (PyGTK 2.10 or later) or
|
||||
false otherwise."""
|
||||
try:
|
||||
gtk.PrintOperation
|
||||
Gtk.PrintOperation
|
||||
except AttributeError:
|
||||
return False
|
||||
else:
|
||||
@@ -140,7 +140,7 @@ class ScanWindow(UmitScanWindow):
|
||||
|
||||
self.scan_interface = ScanInterface()
|
||||
|
||||
self.main_accel_group = gtk.AccelGroup()
|
||||
self.main_accel_group = Gtk.AccelGroup()
|
||||
|
||||
self.add_accel_group(self.main_accel_group)
|
||||
|
||||
@@ -158,12 +158,12 @@ class ScanWindow(UmitScanWindow):
|
||||
def _create_ui_manager(self):
|
||||
"""Creates the UI Manager and a default set of actions, and builds
|
||||
the menus using those actions."""
|
||||
self.ui_manager = gtk.UIManager()
|
||||
self.ui_manager = Gtk.UIManager()
|
||||
|
||||
# See info on ActionGroup at:
|
||||
# * http://www.pygtk.org/pygtk2reference/class-gtkactiongroup.html
|
||||
# * http://www.gtk.org/api/2.6/gtk/GtkActionGroup.html
|
||||
self.main_action_group = gtk.ActionGroup('MainActionGroup')
|
||||
self.main_action_group = Gtk.ActionGroup.new('MainActionGroup')
|
||||
|
||||
# See info on Action at:
|
||||
# * http://www.pygtk.org/pygtk2reference/class-gtkaction.html
|
||||
@@ -177,39 +177,33 @@ class ScanWindow(UmitScanWindow):
|
||||
# _('Open the results of a previous scan'),
|
||||
# lambda x: True)
|
||||
|
||||
# gtk.STOCK_ABOUT is only available in PyGTK 2.6 and later.
|
||||
try:
|
||||
about_icon = gtk.STOCK_ABOUT
|
||||
except AttributeError:
|
||||
about_icon = None
|
||||
|
||||
self.main_actions = [
|
||||
# Top level
|
||||
('Scan', None, _('Sc_an'), None),
|
||||
|
||||
('Save Scan',
|
||||
gtk.STOCK_SAVE,
|
||||
Gtk.STOCK_SAVE,
|
||||
_('_Save Scan'),
|
||||
None,
|
||||
_('Save current scan results'),
|
||||
self._save_scan_results_cb),
|
||||
|
||||
('Save All Scans to Directory',
|
||||
gtk.STOCK_SAVE,
|
||||
Gtk.STOCK_SAVE,
|
||||
_('Save All Scans to _Directory'),
|
||||
"<Control><Alt>s",
|
||||
_('Save all scans into a directory'),
|
||||
self._save_to_directory_cb),
|
||||
|
||||
('Open Scan',
|
||||
gtk.STOCK_OPEN,
|
||||
Gtk.STOCK_OPEN,
|
||||
_('_Open Scan'),
|
||||
None,
|
||||
_('Open the results of a previous scan'),
|
||||
self._load_scan_results_cb),
|
||||
|
||||
('Append Scan',
|
||||
gtk.STOCK_ADD,
|
||||
Gtk.STOCK_ADD,
|
||||
_('_Open Scan in This Window'),
|
||||
None,
|
||||
_('Append a saved scan to the list of scans in this window.'),
|
||||
@@ -219,56 +213,56 @@ class ScanWindow(UmitScanWindow):
|
||||
('Tools', None, _('_Tools'), None),
|
||||
|
||||
('New Window',
|
||||
gtk.STOCK_NEW,
|
||||
Gtk.STOCK_NEW,
|
||||
_('_New Window'),
|
||||
"<Control>N",
|
||||
_('Open a new scan window'),
|
||||
self._new_scan_cb),
|
||||
|
||||
('Close Window',
|
||||
gtk.STOCK_CLOSE,
|
||||
Gtk.STOCK_CLOSE,
|
||||
_('Close Window'),
|
||||
"<Control>w",
|
||||
_('Close this scan window'),
|
||||
self._exit_cb),
|
||||
|
||||
('Print...',
|
||||
gtk.STOCK_PRINT,
|
||||
Gtk.STOCK_PRINT,
|
||||
_('Print...'),
|
||||
None,
|
||||
_('Print the current scan'),
|
||||
self._print_cb),
|
||||
|
||||
('Quit',
|
||||
gtk.STOCK_QUIT,
|
||||
Gtk.STOCK_QUIT,
|
||||
_('Quit'),
|
||||
"<Control>q",
|
||||
_('Quit the application'),
|
||||
self._quit_cb),
|
||||
|
||||
('New Profile',
|
||||
gtk.STOCK_JUSTIFY_LEFT,
|
||||
Gtk.STOCK_JUSTIFY_LEFT,
|
||||
_('New _Profile or Command'),
|
||||
'<Control>p',
|
||||
_('Create a new scan profile using the current command'),
|
||||
self._new_scan_profile_cb),
|
||||
|
||||
('Search Scan',
|
||||
gtk.STOCK_FIND,
|
||||
Gtk.STOCK_FIND,
|
||||
_('Search Scan Results'),
|
||||
'<Control>f',
|
||||
_('Search for a scan result'),
|
||||
self._search_scan_result),
|
||||
|
||||
('Filter Hosts',
|
||||
gtk.STOCK_FIND,
|
||||
Gtk.STOCK_FIND,
|
||||
_('Filter Hosts'),
|
||||
'<Control>l',
|
||||
_('Search for host by criteria'),
|
||||
self._filter_cb),
|
||||
|
||||
('Edit Profile',
|
||||
gtk.STOCK_PROPERTIES,
|
||||
Gtk.STOCK_PROPERTIES,
|
||||
_('_Edit Selected Profile'),
|
||||
'<Control>e',
|
||||
_('Edit selected scan profile'),
|
||||
@@ -278,7 +272,7 @@ class ScanWindow(UmitScanWindow):
|
||||
('Profile', None, _('_Profile'), None),
|
||||
|
||||
('Compare Results',
|
||||
gtk.STOCK_DND_MULTIPLE,
|
||||
Gtk.STOCK_DND_MULTIPLE,
|
||||
_('Compare Results'),
|
||||
"<Control>D",
|
||||
_('Compare Scan Results using Diffies'),
|
||||
@@ -289,7 +283,7 @@ class ScanWindow(UmitScanWindow):
|
||||
('Help', None, _('_Help'), None),
|
||||
|
||||
('Report a bug',
|
||||
gtk.STOCK_DIALOG_INFO,
|
||||
Gtk.STOCK_DIALOG_INFO,
|
||||
_('_Report a bug'),
|
||||
'<Control>b',
|
||||
_("Report a bug"),
|
||||
@@ -297,7 +291,7 @@ class ScanWindow(UmitScanWindow):
|
||||
),
|
||||
|
||||
('About',
|
||||
about_icon,
|
||||
Gtk.STOCK_ABOUT,
|
||||
_('_About'),
|
||||
None,
|
||||
_("About %s") % APP_DISPLAY_NAME,
|
||||
@@ -305,7 +299,7 @@ class ScanWindow(UmitScanWindow):
|
||||
),
|
||||
|
||||
('Show Help',
|
||||
gtk.STOCK_HELP,
|
||||
Gtk.STOCK_HELP,
|
||||
_('_Help'),
|
||||
None,
|
||||
_('Shows the application help'),
|
||||
@@ -410,7 +404,7 @@ class ScanWindow(UmitScanWindow):
|
||||
log.debug(">>> Saving result into database...")
|
||||
try:
|
||||
scan_interface.inventory.save_to_db()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Can't save to database"),
|
||||
secondary_text=_("Can't store unsaved scans to the "
|
||||
@@ -445,7 +439,7 @@ class ScanWindow(UmitScanWindow):
|
||||
menubar = self.ui_manager.get_widget('/menubar')
|
||||
|
||||
if is_maemo():
|
||||
menu = gtk.Menu()
|
||||
menu = Gtk.Menu()
|
||||
for child in menubar.get_children():
|
||||
child.reparent(menu)
|
||||
self.set_menu(menu)
|
||||
@@ -474,7 +468,7 @@ class ScanWindow(UmitScanWindow):
|
||||
|
||||
filename = None
|
||||
response = self._results_filechooser_dialog.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
if response == Gtk.ResponseType.OK:
|
||||
filename = self._results_filechooser_dialog.get_filename()
|
||||
elif response == RESPONSE_OPEN_DIRECTORY:
|
||||
filename = self._results_filechooser_dialog.get_filename()
|
||||
@@ -537,7 +531,7 @@ class ScanWindow(UmitScanWindow):
|
||||
try:
|
||||
# Parse result
|
||||
scan_interface.load_from_file(filename)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
alert = HIGAlertDialog(message_format=_('Error loading file'),
|
||||
secondary_text=str(e))
|
||||
alert.run()
|
||||
@@ -596,20 +590,20 @@ class ScanWindow(UmitScanWindow):
|
||||
dlg = HIGDialog(
|
||||
title="Choose a scan to save",
|
||||
parent=self,
|
||||
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
|
||||
dlg.vbox.pack_start(gtk.Label(
|
||||
flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
||||
dlg.vbox.pack_start(Gtk.Label.new(
|
||||
"You have %u scans loaded in the current view.\n"
|
||||
"Select the scan which you would like to save." % num_scans),
|
||||
False)
|
||||
scan_combo = gtk.combo_box_new_text()
|
||||
False, True, 0)
|
||||
scan_combo = Gtk.ComboBoxText()
|
||||
for scan in self.scan_interface.inventory.get_scans():
|
||||
scan_combo.append_text(scan.nmap_command)
|
||||
scan_combo.set_active(0)
|
||||
dlg.vbox.pack_start(scan_combo, False)
|
||||
dlg.vbox.pack_start(scan_combo, False, True, 0)
|
||||
dlg.vbox.show_all()
|
||||
if dlg.run() == gtk.RESPONSE_OK:
|
||||
if dlg.run() == Gtk.ResponseType.OK:
|
||||
selected = scan_combo.get_active()
|
||||
dlg.destroy()
|
||||
else:
|
||||
@@ -627,7 +621,7 @@ class ScanWindow(UmitScanWindow):
|
||||
response = self._save_results_filechooser_dialog.run()
|
||||
|
||||
filename = None
|
||||
if (response == gtk.RESPONSE_OK):
|
||||
if (response == Gtk.ResponseType.OK):
|
||||
filename = self._save_results_filechooser_dialog.get_filename()
|
||||
format = self._save_results_filechooser_dialog.get_format()
|
||||
# add .xml to filename if there is no other extension
|
||||
@@ -664,12 +658,12 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
# display a directory chooser dialog
|
||||
dir_chooser = SaveToDirectoryChooserDialog(
|
||||
title=_("Choose a directory to save scans into"))
|
||||
if dir_chooser.run() == gtk.RESPONSE_OK:
|
||||
if dir_chooser.run() == Gtk.ResponseType.OK:
|
||||
self._save_all(self.scan_interface, dir_chooser.get_filename())
|
||||
dir_chooser.destroy()
|
||||
|
||||
def _about_cb_response(self, dialog, response_id):
|
||||
if response_id == gtk.RESPONSE_DELETE_EVENT:
|
||||
if response_id == Gtk.ResponseType.DELETE_EVENT:
|
||||
self._about_dialog = None
|
||||
else:
|
||||
self._about_dialog.hide()
|
||||
@@ -687,7 +681,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
filenames = scan_interface.inventory.save_to_dir(directory)
|
||||
for scan in scan_interface.inventory.get_scans():
|
||||
scan.unsaved = False
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
alert = HIGAlertDialog(message_format=_('Can\'t save file'),
|
||||
secondary_text=str(ex))
|
||||
alert.run()
|
||||
@@ -700,7 +694,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
for filename in filenames:
|
||||
recent_scans.add_recent_scan(filename)
|
||||
recent_scans.save()
|
||||
except (OSError, IOError), e:
|
||||
except (OSError, IOError) as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_(
|
||||
"Can't save recent scan information"),
|
||||
@@ -718,7 +712,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
scan_interface.inventory.save_to_file(
|
||||
saved_filename, selected_index, format)
|
||||
scan_interface.inventory.get_scans()[selected_index].unsaved = False # noqa
|
||||
except (OSError, IOError), e:
|
||||
except (OSError, IOError) as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_("Can't save file"),
|
||||
secondary_text=_("Can't open file to write.\n%s") % str(e))
|
||||
@@ -735,7 +729,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
try:
|
||||
recent_scans.add_recent_scan(saved_filename)
|
||||
recent_scans.save()
|
||||
except (OSError, IOError), e:
|
||||
except (OSError, IOError) as e:
|
||||
alert = HIGAlertDialog(
|
||||
message_format=_(
|
||||
"Can't save recent scan information"),
|
||||
@@ -772,7 +766,7 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
pe.show_all()
|
||||
|
||||
def _help_cb(self, action):
|
||||
show_help()
|
||||
self.show_help()
|
||||
|
||||
def _exit_cb(self, *args):
|
||||
"""Closes the window, prompting for confirmation if necessary. If one
|
||||
@@ -781,9 +775,9 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
if self.scan_interface.changed:
|
||||
log.debug("Found changes on closing window")
|
||||
dialog = HIGDialog(
|
||||
buttons=(_('Close anyway').encode('utf-8'),
|
||||
gtk.RESPONSE_CLOSE, gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL))
|
||||
buttons=(_('Close anyway'),
|
||||
Gtk.ResponseType.CLOSE, Gtk.STOCK_CANCEL,
|
||||
Gtk.ResponseType.CANCEL))
|
||||
|
||||
alert = HIGEntryLabel('<b>%s</b>' % _("Unsaved changes"))
|
||||
|
||||
@@ -797,22 +791,22 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = gtk.Image()
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
|
||||
Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert)
|
||||
vbox.pack_start(text)
|
||||
hbox.pack_start(image)
|
||||
hbox.pack_start(vbox)
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
hbox.pack_start(image, True, True, 0)
|
||||
hbox.pack_start(vbox, True, True, 0)
|
||||
|
||||
dialog.vbox.pack_start(hbox)
|
||||
dialog.vbox.pack_start(hbox, True, True, 0)
|
||||
dialog.vbox.show_all()
|
||||
|
||||
response = dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
if response == gtk.RESPONSE_CANCEL:
|
||||
if response == Gtk.ResponseType.CANCEL:
|
||||
return True
|
||||
|
||||
search_config = SearchConfig()
|
||||
@@ -822,9 +816,9 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
elif self.scan_interface.num_scans_running() > 0:
|
||||
log.debug("Trying to close a window with a running scan")
|
||||
dialog = HIGDialog(
|
||||
buttons=(_('Close anyway').encode('utf-8'),
|
||||
gtk.RESPONSE_CLOSE, gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL))
|
||||
buttons=(_('Close anyway'),
|
||||
Gtk.ResponseType.CLOSE, Gtk.STOCK_CANCEL,
|
||||
Gtk.ResponseType.CANCEL))
|
||||
|
||||
alert = HIGEntryLabel('<b>%s</b>' % _("Trying to close"))
|
||||
|
||||
@@ -839,24 +833,24 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = gtk.Image()
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
|
||||
Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert)
|
||||
vbox.pack_start(text)
|
||||
hbox.pack_start(image)
|
||||
hbox.pack_start(vbox)
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
hbox.pack_start(image, True, True, 0)
|
||||
hbox.pack_start(vbox, True, True, 0)
|
||||
|
||||
dialog.vbox.pack_start(hbox)
|
||||
dialog.vbox.pack_start(hbox, True, True, 0)
|
||||
dialog.vbox.show_all()
|
||||
|
||||
response = dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
if response == gtk.RESPONSE_CLOSE:
|
||||
if response == Gtk.ResponseType.CLOSE:
|
||||
self.scan_interface.kill_all_scans()
|
||||
elif response == gtk.RESPONSE_CANCEL:
|
||||
elif response == Gtk.ResponseType.CANCEL:
|
||||
return True
|
||||
|
||||
window = WindowConfig()
|
||||
@@ -902,29 +896,26 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
|
||||
self.diff_window.show_all()
|
||||
|
||||
|
||||
def show_help():
|
||||
import urllib
|
||||
def show_help(self):
|
||||
import urllib.request
|
||||
import webbrowser
|
||||
|
||||
new = 0
|
||||
if sys.hexversion >= 0x2050000:
|
||||
new = 2
|
||||
|
||||
doc_path = abspath(join(Path.docs_dir, "help.html"))
|
||||
url = "file:" + urllib.pathname2url(fs_enc(doc_path))
|
||||
url = "file:" + urllib.request.pathname2url(doc_path)
|
||||
|
||||
try:
|
||||
webbrowser.open(url, new=new)
|
||||
except OSError, e:
|
||||
webbrowser.open(url, new=2)
|
||||
except OSError as e:
|
||||
d = HIGAlertDialog(parent=self,
|
||||
message_format=_("Can't find documentation files"),
|
||||
secondary_text=_("""\
|
||||
There was an error loading the documentation file %s (%s). See the \
|
||||
online documentation at %s.\
|
||||
""") % (doc_path, unicode(e), APP_DOCUMENTATION_SITE))
|
||||
""") % (doc_path, str(e), APP_DOCUMENTATION_SITE))
|
||||
d.run()
|
||||
d.destroy()
|
||||
|
||||
if __name__ == '__main__':
|
||||
w = ScanWindow()
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,9 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
from zenmapCore.UmitConf import NmapOutputHighlight
|
||||
@@ -76,7 +76,7 @@ from zenmapGUI.higwidgets.higbuttons import HIGButton, HIGToggleButton
|
||||
class NmapOutputProperties(HIGDialog):
|
||||
def __init__(self, nmap_output_view):
|
||||
HIGDialog.__init__(self, _("Nmap Output Properties"),
|
||||
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
|
||||
buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
|
||||
|
||||
self.nmap_highlight = NmapOutputHighlight()
|
||||
|
||||
@@ -90,7 +90,7 @@ class NmapOutputProperties(HIGDialog):
|
||||
self.properties_notebook = HIGNotebook()
|
||||
|
||||
def __pack_widgets(self):
|
||||
self.vbox.pack_start(self.properties_notebook)
|
||||
self.vbox.pack_start(self.properties_notebook, True, True, 0)
|
||||
|
||||
def highlight_tab(self):
|
||||
# Creating highlight tab main box
|
||||
@@ -121,8 +121,8 @@ class NmapOutputProperties(HIGDialog):
|
||||
self.property_names[p].append(settings[0])
|
||||
self.property_names[p].append(settings[1])
|
||||
self.property_names[p].append(settings[2])
|
||||
self.property_names[p].append(gtk.gdk.Color(*settings[3]))
|
||||
self.property_names[p].append(gtk.gdk.Color(*settings[4]))
|
||||
self.property_names[p].append(Gdk.Color(*settings[3]))
|
||||
self.property_names[p].append(Gdk.Color(*settings[4]))
|
||||
self.property_names[p].append(settings[5])
|
||||
|
||||
# Creating properties and related widgets and attaching it to main
|
||||
@@ -152,12 +152,12 @@ class NmapOutputProperties(HIGDialog):
|
||||
y2 += 1
|
||||
|
||||
# Packing main table into main vbox
|
||||
self.highlight_main_vbox.pack_start(self.highlight_main_table)
|
||||
self.highlight_main_vbox.pack_start(self.highlight_main_table, True, True, 0)
|
||||
|
||||
# Adding color tab
|
||||
self.properties_notebook.append_page(
|
||||
self.highlight_main_vbox,
|
||||
gtk.Label(_("Highlight definitions")))
|
||||
Gtk.Label.new(_("Highlight definitions")))
|
||||
|
||||
|
||||
class HighlightProperty(object):
|
||||
@@ -180,13 +180,13 @@ class HighlightProperty(object):
|
||||
def __create_widgets(self):
|
||||
self.property_name_label = HIGEntryLabel("")
|
||||
self.example_label = HIGEntryLabel("")
|
||||
self.bold_tg_button = HIGToggleButton("", gtk.STOCK_BOLD)
|
||||
self.italic_tg_button = HIGToggleButton("", gtk.STOCK_ITALIC)
|
||||
self.underline_tg_button = HIGToggleButton("", gtk.STOCK_UNDERLINE)
|
||||
self.bold_tg_button = HIGToggleButton("", Gtk.STOCK_BOLD)
|
||||
self.italic_tg_button = HIGToggleButton("", Gtk.STOCK_ITALIC)
|
||||
self.underline_tg_button = HIGToggleButton("", Gtk.STOCK_UNDERLINE)
|
||||
self.text_color_button = HIGButton(
|
||||
_("Text"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
_("Text"), stock=Gtk.STOCK_SELECT_COLOR)
|
||||
self.highlight_color_button = HIGButton(
|
||||
_("Highlight"), stock=gtk.STOCK_SELECT_COLOR)
|
||||
_("Highlight"), stock=Gtk.STOCK_SELECT_COLOR)
|
||||
|
||||
def __connect_buttons(self):
|
||||
self.bold_tg_button.connect("toggled", self.update_example)
|
||||
@@ -201,13 +201,13 @@ class HighlightProperty(object):
|
||||
# Text color dialog
|
||||
|
||||
def text_color_dialog(self, widget):
|
||||
color_dialog = gtk.ColorSelectionDialog(
|
||||
color_dialog = Gtk.ColorSelectionDialog.new(
|
||||
"%s %s" % (self.label, _("text color")))
|
||||
color_dialog.colorsel.set_current_color(self.text_color)
|
||||
color_dialog.get_color_selection().set_current_color(self.text_color)
|
||||
|
||||
color_dialog.ok_button.connect(
|
||||
color_dialog.props.ok_button.connect(
|
||||
"clicked", self.text_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect(
|
||||
color_dialog.props.cancel_button.connect(
|
||||
"clicked", self.text_color_dialog_cancel, color_dialog)
|
||||
color_dialog.connect(
|
||||
"delete-event", self.text_color_dialog_close, color_dialog)
|
||||
@@ -215,7 +215,7 @@ class HighlightProperty(object):
|
||||
color_dialog.run()
|
||||
|
||||
def text_color_dialog_ok(self, widget, color_dialog):
|
||||
self.text_color = color_dialog.colorsel.get_current_color()
|
||||
self.text_color = color_dialog.get_color_selection().get_current_color()
|
||||
color_dialog.destroy()
|
||||
self.update_example()
|
||||
|
||||
@@ -228,13 +228,13 @@ class HighlightProperty(object):
|
||||
#########################################
|
||||
# Highlight color dialog
|
||||
def highlight_color_dialog(self, widget):
|
||||
color_dialog = gtk.ColorSelectionDialog(
|
||||
color_dialog = Gtk.ColorSelectionDialog.new(
|
||||
"%s %s" % (self.property_name, _("highlight color")))
|
||||
color_dialog.colorsel.set_current_color(self.highlight_color)
|
||||
color_dialog.get_color_selection().set_current_color(self.highlight_color)
|
||||
|
||||
color_dialog.ok_button.connect(
|
||||
color_dialog.props.ok_button.connect(
|
||||
"clicked", self.highlight_color_dialog_ok, color_dialog)
|
||||
color_dialog.cancel_button.connect(
|
||||
color_dialog.props.cancel_button.connect(
|
||||
"clicked", self.highlight_color_dialog_cancel,
|
||||
color_dialog)
|
||||
color_dialog.connect(
|
||||
@@ -244,7 +244,7 @@ class HighlightProperty(object):
|
||||
color_dialog.run()
|
||||
|
||||
def highlight_color_dialog_ok(self, widget, color_dialog):
|
||||
self.highlight_color = color_dialog.colorsel.get_current_color()
|
||||
self.highlight_color = color_dialog.get_color_selection().get_current_color()
|
||||
color_dialog.destroy()
|
||||
self.update_example()
|
||||
|
||||
@@ -255,41 +255,23 @@ class HighlightProperty(object):
|
||||
color_dialog.destroy()
|
||||
|
||||
def update_example(self, widget=None):
|
||||
start = 0
|
||||
end = len(self.example)
|
||||
|
||||
attributes = pango.AttrList()
|
||||
|
||||
attributes.insert(
|
||||
pango.AttrForeground(self.text_color.red,
|
||||
self.text_color.green, self.text_color.blue, start, end))
|
||||
attributes.insert(pango.AttrBackground(self.highlight_color.red,
|
||||
self.highlight_color.green,
|
||||
self.highlight_color.blue,
|
||||
start, end))
|
||||
label = self.example_label.get_text()
|
||||
|
||||
# Bold verification
|
||||
if self.bold_tg_button.get_active():
|
||||
attributes.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, start, end))
|
||||
else:
|
||||
attributes.insert(
|
||||
pango.AttrWeight(pango.WEIGHT_NORMAL, start, end))
|
||||
label = "<b>" + label + "</b>"
|
||||
|
||||
# Italic verification
|
||||
if self.italic_tg_button.get_active():
|
||||
attributes.insert(pango.AttrStyle(pango.STYLE_ITALIC, start, end))
|
||||
else:
|
||||
attributes.insert(pango.AttrStyle(pango.STYLE_NORMAL, start, end))
|
||||
label = "<i>" + label + "</i>"
|
||||
|
||||
# Underline verification
|
||||
if self.underline_tg_button.get_active():
|
||||
attributes.insert(
|
||||
pango.AttrUnderline(pango.UNDERLINE_SINGLE, start, end))
|
||||
else:
|
||||
attributes.insert(
|
||||
pango.AttrUnderline(pango.UNDERLINE_NONE, start, end))
|
||||
label = "<u>" + label + "</u>"
|
||||
|
||||
self.example_label.set_attributes(attributes)
|
||||
self.example_label.modify_fg(Gtk.StateType.NORMAL, self.text_color)
|
||||
self.example_label.modify_bg(Gtk.StateType.NORMAL, self.highlight_color)
|
||||
self.example_label.set_markup(label)
|
||||
|
||||
def show_bold(self, widget):
|
||||
self.example_label.set_markup("<>")
|
||||
@@ -339,4 +321,4 @@ class HighlightProperty(object):
|
||||
if __name__ == "__main__":
|
||||
n = NmapOutputProperties(None)
|
||||
n.run()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,10 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk, Pango, GLib
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import pango
|
||||
import re
|
||||
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
@@ -71,13 +72,13 @@ from zenmapCore.UmitConf import NmapOutputHighlight
|
||||
from zenmapGUI.NmapOutputProperties import NmapOutputProperties
|
||||
|
||||
|
||||
class NmapOutputViewer (gtk.VBox):
|
||||
class NmapOutputViewer(Gtk.Box):
|
||||
HIGHLIGHT_PROPERTIES = ["details", "date", "hostname", "ip", "port_list",
|
||||
"open_port", "closed_port", "filtered_port"]
|
||||
|
||||
def __init__(self, refresh=1, stop=1):
|
||||
self.nmap_highlight = NmapOutputHighlight()
|
||||
gtk.VBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
# Creating widgets
|
||||
self.__create_widgets()
|
||||
@@ -95,7 +96,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
self.refreshing = True
|
||||
|
||||
# Adding widgets to the VBox
|
||||
self.pack_start(self.scrolled, expand=True, fill=True)
|
||||
self.pack_start(self.scrolled, True, True, 0)
|
||||
|
||||
# The NmapCommand instance, if any, whose output is shown in this
|
||||
# display.
|
||||
@@ -105,17 +106,17 @@ class NmapOutputViewer (gtk.VBox):
|
||||
|
||||
def __create_widgets(self):
|
||||
# Creating widgets
|
||||
self.scrolled = gtk.ScrolledWindow()
|
||||
self.text_view = gtk.TextView()
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
self.text_view = Gtk.TextView()
|
||||
|
||||
def __set_scrolled_window(self):
|
||||
# Seting scrolled window
|
||||
self.scrolled.set_border_width(5)
|
||||
self.scrolled.add(self.text_view)
|
||||
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def __set_text_view(self):
|
||||
self.text_view.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.text_view.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.text_view.set_editable(False)
|
||||
|
||||
self.tag_font = self.text_view.get_buffer().create_tag(None)
|
||||
@@ -125,29 +126,27 @@ class NmapOutputViewer (gtk.VBox):
|
||||
tag = self.text_view.get_buffer().create_tag(property)
|
||||
|
||||
if settings[0]:
|
||||
tag.set_property("weight", pango.WEIGHT_HEAVY)
|
||||
tag.set_property("weight", Pango.Weight.HEAVY)
|
||||
else:
|
||||
tag.set_property("weight", pango.WEIGHT_NORMAL)
|
||||
tag.set_property("weight", Pango.Weight.NORMAL)
|
||||
|
||||
if settings[1]:
|
||||
tag.set_property("style", pango.STYLE_ITALIC)
|
||||
tag.set_property("style", Pango.Style.ITALIC)
|
||||
else:
|
||||
tag.set_property("style", pango.STYLE_NORMAL)
|
||||
tag.set_property("style", Pango.Style.NORMAL)
|
||||
|
||||
if settings[2]:
|
||||
tag.set_property("underline", pango.UNDERLINE_SINGLE)
|
||||
tag.set_property("underline", Pango.Underline.SINGLE)
|
||||
else:
|
||||
tag.set_property("underline", pango.UNDERLINE_NONE)
|
||||
tag.set_property("underline", Pango.Underline.NONE)
|
||||
|
||||
text_color = settings[3]
|
||||
highlight_color = settings[4]
|
||||
|
||||
tag.set_property(
|
||||
"foreground", gtk.color_selection_palette_to_string(
|
||||
[gtk.gdk.Color(*text_color), ]))
|
||||
"foreground", Gdk.Color(*text_color).to_string())
|
||||
tag.set_property(
|
||||
"background", gtk.color_selection_palette_to_string(
|
||||
[gtk.gdk.Color(*highlight_color), ]))
|
||||
"background", Gdk.Color(*highlight_color).to_string())
|
||||
|
||||
def go_to_host(self, host):
|
||||
"""Go to host line on nmap output result"""
|
||||
@@ -155,7 +154,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
start_iter = buff.get_start_iter()
|
||||
|
||||
found_tuple = start_iter.forward_search(
|
||||
"\nNmap scan report for %s\n" % host, gtk.TEXT_SEARCH_TEXT_ONLY
|
||||
"\nNmap scan report for %s\n" % host, Gtk.TextSearchFlags.TEXT_ONLY
|
||||
)
|
||||
if found_tuple is None:
|
||||
return
|
||||
@@ -219,7 +218,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
if not self.nmap_highlight.enable:
|
||||
return
|
||||
|
||||
text = buf.get_text(start_iter, end_iter)
|
||||
text = buf.get_text(start_iter, end_iter, include_hidden_chars=True)
|
||||
|
||||
for property in self.HIGHLIGHT_PROPERTIES:
|
||||
settings = self.nmap_highlight.__getattribute__(property)
|
||||
@@ -243,7 +242,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
The current output is extracted from the command object."""
|
||||
self.command_execution = command
|
||||
if command is not None:
|
||||
self.text_view.get_buffer().set_text(u"")
|
||||
self.text_view.get_buffer().set_text("")
|
||||
self.output_file_pointer = 0
|
||||
else:
|
||||
self.output_file_pointer = None
|
||||
@@ -297,7 +296,7 @@ class NmapOutputViewer (gtk.VBox):
|
||||
v_adj = self.scrolled.get_vadjustment()
|
||||
if new_output and v_adj is not None:
|
||||
# Find out if the view is already scrolled to the bottom.
|
||||
at_end = (v_adj.value >= v_adj.upper - v_adj.page_size)
|
||||
at_end = (v_adj.get_value() >= v_adj.get_upper() - v_adj.get_page_size())
|
||||
|
||||
buf = self.text_view.get_buffer()
|
||||
prev_end_mark = buf.create_mark(
|
||||
@@ -318,6 +317,6 @@ class NmapOutputViewer (gtk.VBox):
|
||||
# text causes a scroll bar to appear and reflow the text,
|
||||
# making the text a bit taller.
|
||||
self.text_view.scroll_mark_onscreen(self.end_mark)
|
||||
gobject.idle_add(
|
||||
GLib.idle_add(
|
||||
lambda: self.text_view.scroll_mark_onscreen(
|
||||
self.end_mark))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
|
||||
# Prevent loading PyXML
|
||||
@@ -101,9 +102,9 @@ def get_option_check_auxiliary_widget(option, ops, check):
|
||||
assert False, "Unknown option %s" % option
|
||||
|
||||
|
||||
class OptionEntry(gtk.Entry):
|
||||
class OptionEntry(Gtk.Entry):
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.Entry.__init__(self)
|
||||
Gtk.Entry.__init__(self)
|
||||
self.option = option
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
@@ -121,18 +122,18 @@ class OptionEntry(gtk.Entry):
|
||||
|
||||
def check_toggled_cb(self, check):
|
||||
if check.get_active():
|
||||
self.ops[self.option] = self.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.get_text()
|
||||
else:
|
||||
self.ops[self.option] = None
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.check.set_active(True)
|
||||
self.ops[self.option] = self.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.get_text()
|
||||
|
||||
|
||||
class OptionExtras(gtk.Entry):
|
||||
class OptionExtras(Gtk.Entry):
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.Entry.__init__(self)
|
||||
Gtk.Entry.__init__(self)
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
self.connect("changed", self.changed_cb)
|
||||
@@ -149,18 +150,19 @@ class OptionExtras(gtk.Entry):
|
||||
|
||||
def check_toggled_cb(self, check):
|
||||
if check.get_active():
|
||||
self.ops.extras = [self.get_text().decode("UTF-8")]
|
||||
self.ops.extras = [self.get_text()]
|
||||
else:
|
||||
self.ops.extras = []
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.check.set_active(True)
|
||||
self.ops.extras = [self.get_text().decode("UTF-8")]
|
||||
self.ops.extras = [self.get_text()]
|
||||
|
||||
|
||||
class OptionLevel(gtk.SpinButton):
|
||||
class OptionLevel(Gtk.SpinButton):
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.SpinButton.__init__(self, gtk.Adjustment(0, 0, 10, 1), 0.0, 0)
|
||||
adjustment = Gtk.Adjustment.new(0, 0, 10, 1, 0, 0)
|
||||
Gtk.SpinButton.__init__(self, adjustment=adjustment, climb_rate=0.0, digits=0)
|
||||
self.option = option
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
@@ -188,22 +190,22 @@ class OptionLevel(gtk.SpinButton):
|
||||
self.ops[self.option] = int(self.get_adjustment().get_value())
|
||||
|
||||
|
||||
class OptionFile(gtk.HBox):
|
||||
class OptionFile(Gtk.Box):
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, option, ops, check):
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.option = option
|
||||
self.ops = ops
|
||||
self.check = check
|
||||
|
||||
self.entry = gtk.Entry()
|
||||
self.pack_start(self.entry, True, True)
|
||||
button = HIGButton(stock=gtk.STOCK_OPEN)
|
||||
self.pack_start(button, False)
|
||||
self.entry = Gtk.Entry()
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
button = HIGButton(stock=Gtk.STOCK_OPEN)
|
||||
self.pack_start(button, False, True, 0)
|
||||
|
||||
button.connect("clicked", self.clicked_cb)
|
||||
|
||||
@@ -222,36 +224,36 @@ class OptionFile(gtk.HBox):
|
||||
|
||||
def check_toggled_cb(self, check):
|
||||
if check.get_active():
|
||||
self.ops[self.option] = self.entry.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.entry.get_text()
|
||||
else:
|
||||
self.ops[self.option] = None
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.check.set_active(True)
|
||||
self.ops[self.option] = self.entry.get_text().decode("UTF-8")
|
||||
self.ops[self.option] = self.entry.get_text()
|
||||
|
||||
def clicked_cb(self, button):
|
||||
dialog = AllFilesFileChooserDialog(_("Choose file"))
|
||||
if dialog.run() == gtk.RESPONSE_OK:
|
||||
if dialog.run() == Gtk.ResponseType.OK:
|
||||
self.entry.set_text(dialog.get_filename())
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
class TargetEntry(gtk.Entry):
|
||||
class TargetEntry(Gtk.Entry):
|
||||
def __init__(self, ops):
|
||||
gtk.Entry.__init__(self)
|
||||
Gtk.Entry.__init__(self)
|
||||
self.ops = ops
|
||||
self.connect("changed", self.changed_cb)
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
self.set_text(u" ".join(self.ops.target_specs))
|
||||
self.set_text(" ".join(self.ops.target_specs))
|
||||
|
||||
def changed_cb(self, widget):
|
||||
self.ops.target_specs = self.get_targets()
|
||||
|
||||
def get_targets(self):
|
||||
return split_quoted(self.get_text().decode("UTF-8"))
|
||||
return split_quoted(self.get_text())
|
||||
|
||||
|
||||
class OptionTab(object):
|
||||
@@ -275,29 +277,29 @@ class OptionTab(object):
|
||||
self.widgets_list.append(widget)
|
||||
|
||||
def __parse_target(self, target_element):
|
||||
label = _(target_element.getAttribute(u'label'))
|
||||
label = _(target_element.getAttribute('label'))
|
||||
label_widget = HIGEntryLabel(label)
|
||||
target_widget = TargetEntry(self.ops)
|
||||
target_widget.connect("changed", self.update_target)
|
||||
return label_widget, target_widget
|
||||
|
||||
def __parse_option_list(self, option_list_element):
|
||||
children = option_list_element.getElementsByTagName(u'option')
|
||||
children = option_list_element.getElementsByTagName('option')
|
||||
|
||||
label_widget = HIGEntryLabel(
|
||||
_(option_list_element.getAttribute(u'label')))
|
||||
_(option_list_element.getAttribute('label')))
|
||||
option_list_widget = OptionList(self.ops)
|
||||
|
||||
for child in children:
|
||||
option = child.getAttribute(u'option')
|
||||
argument = child.getAttribute(u'argument')
|
||||
label = _(child.getAttribute(u'label'))
|
||||
option = child.getAttribute('option')
|
||||
argument = child.getAttribute('argument')
|
||||
label = _(child.getAttribute('label'))
|
||||
option_list_widget.append(option, argument, label)
|
||||
self.profilehelp.add_label(option, label)
|
||||
self.profilehelp.add_shortdesc(
|
||||
option, _(child.getAttribute(u'short_desc')))
|
||||
option, _(child.getAttribute('short_desc')))
|
||||
self.profilehelp.add_example(
|
||||
option, child.getAttribute(u'example'))
|
||||
option, child.getAttribute('example'))
|
||||
|
||||
option_list_widget.update()
|
||||
|
||||
@@ -306,10 +308,10 @@ class OptionTab(object):
|
||||
return label_widget, option_list_widget
|
||||
|
||||
def __parse_option_check(self, option_check):
|
||||
option = option_check.getAttribute(u'option')
|
||||
label = _(option_check.getAttribute(u'label'))
|
||||
short_desc = _(option_check.getAttribute(u'short_desc'))
|
||||
example = option_check.getAttribute(u'example')
|
||||
option = option_check.getAttribute('option')
|
||||
label = _(option_check.getAttribute('label'))
|
||||
short_desc = _(option_check.getAttribute('short_desc'))
|
||||
example = option_check.getAttribute('example')
|
||||
|
||||
self.profilehelp.add_label(option, label)
|
||||
self.profilehelp.add_shortdesc(option, short_desc)
|
||||
@@ -331,7 +333,7 @@ class OptionTab(object):
|
||||
return check, auxiliary_widget
|
||||
|
||||
def fill_table(self, table, expand_fill=True):
|
||||
yopt = (0, gtk.EXPAND | gtk.FILL)[expand_fill]
|
||||
yopt = (0, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL)[expand_fill]
|
||||
for y, widget in enumerate(self.widgets_list):
|
||||
if widget[1] is None:
|
||||
table.attach(widget[0], 0, 2, y, y + 1, yoptions=yopt)
|
||||
@@ -427,12 +429,12 @@ class OptionBuilder(object):
|
||||
dic = {}
|
||||
for group in self.groups:
|
||||
grp = self.xml.getElementsByTagName(group)[0]
|
||||
dic[group] = grp.getAttribute(u'label')
|
||||
dic[group] = grp.getAttribute('label')
|
||||
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')] # noqa
|
||||
return [g_name.getAttribute('name') for g_name in
|
||||
self.xml.getElementsByTagName('groups')[0].getElementsByTagName('group')] # noqa
|
||||
|
||||
def __parse_tabs(self):
|
||||
dic = {}
|
||||
@@ -448,14 +450,14 @@ class OptionBuilder(object):
|
||||
return dic
|
||||
|
||||
|
||||
class OptionList(gtk.ComboBox):
|
||||
class OptionList(Gtk.ComboBox):
|
||||
def __init__(self, ops):
|
||||
self.ops = ops
|
||||
|
||||
self.list = gtk.ListStore(str, str, str)
|
||||
gtk.ComboBox.__init__(self, self.list)
|
||||
self.list = Gtk.ListStore.new([str, str, str])
|
||||
Gtk.ComboBox.__init__(self, model=self.list)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cell = Gtk.CellRendererText()
|
||||
self.pack_start(cell, True)
|
||||
self.add_attribute(cell, 'text', 2)
|
||||
|
||||
@@ -487,12 +489,12 @@ class OptionList(gtk.ComboBox):
|
||||
self.options.append(option)
|
||||
|
||||
|
||||
class OptionCheck(gtk.CheckButton):
|
||||
class OptionCheck(Gtk.CheckButton):
|
||||
def __init__(self, option, label):
|
||||
opt = label
|
||||
if option is not None and option != "":
|
||||
opt += " (%s)" % option
|
||||
|
||||
gtk.CheckButton.__init__(self, opt, use_underline=False)
|
||||
Gtk.CheckButton.__init__(self, label=opt, use_underline=False)
|
||||
|
||||
self.option = option
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -71,15 +70,17 @@
|
||||
# Add options to the print dialog to control the font, coloring, and anything
|
||||
# else. This might go in a separate Print Setup dialog.
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
import gi
|
||||
|
||||
MONOSPACE_FONT_DESC = pango.FontDescription("Monospace 12")
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("PangoCairo", "1.0")
|
||||
from gi.repository import Gtk, GLib, Pango, PangoCairo
|
||||
|
||||
MONOSPACE_FONT_DESC = Pango.FontDescription("Monospace 12")
|
||||
|
||||
|
||||
class PrintState (object):
|
||||
"""This is the userdatum passed to gtk.PrintOperation callbacks."""
|
||||
class PrintState(object):
|
||||
"""This is the userdatum passed to Gtk.PrintOperation callbacks."""
|
||||
|
||||
def __init__(self, inventory, entry):
|
||||
"""entry is a ScansListStoreEntry."""
|
||||
@@ -90,7 +91,7 @@ class PrintState (object):
|
||||
# Still running, failed, or cancelled.
|
||||
output = entry.command.get_output()
|
||||
if not output:
|
||||
output = u"\n"
|
||||
output = "\n"
|
||||
self.lines = output.splitlines()
|
||||
|
||||
def begin_print(self, op, context):
|
||||
@@ -98,14 +99,14 @@ class PrintState (object):
|
||||
# Typeset a dummy line to get the exact line height.
|
||||
layout = context.create_pango_layout()
|
||||
layout.set_font_description(MONOSPACE_FONT_DESC)
|
||||
layout.set_text("dummy")
|
||||
layout.set_text("dummy", -1)
|
||||
line = layout.get_line(0)
|
||||
# get_extents()[1][3] is the height of the logical rectangle.
|
||||
line_height = line.get_extents()[1][3] / float(pango.SCALE)
|
||||
# get_extents()[1].height is the height of the logical rectangle.
|
||||
line_height = line.get_extents()[1].height / Pango.SCALE
|
||||
|
||||
page_height = context.get_height()
|
||||
self.lines_per_page = int(page_height / line_height)
|
||||
op.set_n_pages((len(self.lines) - 1) / self.lines_per_page + 1)
|
||||
op.set_n_pages((len(self.lines) - 1) // self.lines_per_page + 1)
|
||||
|
||||
def draw_page(self, op, context, page_nr):
|
||||
this_page_lines = self.lines[
|
||||
@@ -115,21 +116,21 @@ class PrintState (object):
|
||||
# Do no wrapping.
|
||||
layout.set_width(-1)
|
||||
layout.set_font_description(MONOSPACE_FONT_DESC)
|
||||
text = "\n".join(this_page_lines).encode("utf8")
|
||||
layout.set_text(text)
|
||||
text = "\n".join(this_page_lines)
|
||||
layout.set_text(text, -1)
|
||||
|
||||
cr = context.get_cairo_context()
|
||||
cr.show_layout(layout)
|
||||
PangoCairo.show_layout(cr, layout)
|
||||
|
||||
|
||||
def run_print_operation(inventory, entry):
|
||||
op = gtk.PrintOperation()
|
||||
op = Gtk.PrintOperation()
|
||||
state = PrintState(inventory, entry)
|
||||
op.connect("begin-print", state.begin_print)
|
||||
op.connect("draw-page", state.draw_page)
|
||||
try:
|
||||
op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, None)
|
||||
except gobject.GError:
|
||||
op.run(Gtk.PrintOperationAction.PRINT_DIALOG, None)
|
||||
except GLib.GError:
|
||||
# Canceling the print operation can result in the error
|
||||
# GError: Error from StartDoc
|
||||
# http://seclists.org/nmap-dev/2012/q4/161
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,31 +57,31 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapCore.UmitConf import CommandProfile
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
|
||||
class ProfileCombo(gtk.ComboBoxEntry, object):
|
||||
class ProfileCombo(Gtk.ComboBoxText, object):
|
||||
def __init__(self):
|
||||
gtk.ComboBoxEntry.__init__(self, gtk.ListStore(str), 0)
|
||||
Gtk.ComboBoxText.__init__(self, has_entry=True)
|
||||
|
||||
self.completion = gtk.EntryCompletion()
|
||||
self.child.set_completion(self.completion)
|
||||
self.completion = Gtk.EntryCompletion()
|
||||
self.get_child().set_completion(self.completion)
|
||||
self.completion.set_model(self.get_model())
|
||||
self.completion.set_text_column(0)
|
||||
|
||||
self.update()
|
||||
|
||||
def set_profiles(self, profiles):
|
||||
list = self.get_model()
|
||||
for i in range(len(list)):
|
||||
iter = list.get_iter_root()
|
||||
del(list[iter])
|
||||
self.remove_all()
|
||||
|
||||
for command in profiles:
|
||||
list.append([command])
|
||||
self.append_text(command)
|
||||
|
||||
def update(self):
|
||||
profile = CommandProfile()
|
||||
@@ -93,18 +92,19 @@ class ProfileCombo(gtk.ComboBoxEntry, object):
|
||||
self.set_profiles(profiles)
|
||||
|
||||
def get_selected_profile(self):
|
||||
return self.child.get_text()
|
||||
return self.get_child().get_text()
|
||||
|
||||
def set_selected_profile(self, profile):
|
||||
self.child.set_text(profile)
|
||||
self.get_child().set_text(profile)
|
||||
|
||||
selected_profile = property(get_selected_profile, set_selected_profile)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
p = ProfileCombo()
|
||||
p.update()
|
||||
w.add(p)
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higwindows import HIGWindow
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox, HIGHBox, HIGSpacer, \
|
||||
@@ -83,7 +85,7 @@ class ProfileEditor(HIGWindow):
|
||||
HIGWindow.__init__(self)
|
||||
self.connect("delete_event", self.exit)
|
||||
self.set_title(_('Profile Editor'))
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
self.deletable = deletable
|
||||
self.profile_name = profile_name
|
||||
@@ -130,7 +132,7 @@ class ProfileEditor(HIGWindow):
|
||||
self.update_command()
|
||||
|
||||
def command_entry_changed_cb(self, widget):
|
||||
command_string = self.command_entry.get_text().decode("UTF-8")
|
||||
command_string = self.command_entry.get_text()
|
||||
self.ops.parse_string(command_string)
|
||||
self.inhibit_command_update = True
|
||||
self.option_builder.update()
|
||||
@@ -167,20 +169,21 @@ class ProfileEditor(HIGWindow):
|
||||
self.lower_box = HIGHBox()
|
||||
|
||||
#self.main_vbox = HIGVBox()
|
||||
self.command_entry = gtk.Entry()
|
||||
self.command_entry = Gtk.Entry()
|
||||
self.command_entry_changed_cb_id = self.command_entry.connect(
|
||||
"changed", self.command_entry_changed_cb)
|
||||
|
||||
self.scan_button = HIGButton(_("Scan"))
|
||||
self.scan_button.connect("clicked", self.run_scan)
|
||||
|
||||
self.notebook = gtk.Notebook()
|
||||
self.notebook = Gtk.Notebook()
|
||||
|
||||
# Profile info page
|
||||
self.profile_info_vbox = HIGVBox()
|
||||
self.profile_info_label = HIGSectionLabel(_('Profile Information'))
|
||||
self.profile_name_label = HIGEntryLabel(_('Profile name'))
|
||||
self.profile_name_entry = gtk.Entry()
|
||||
self.profile_name_label.set_line_wrap(False)
|
||||
self.profile_name_entry = Gtk.Entry()
|
||||
self.profile_name_entry.connect(
|
||||
'enter-notify-event', self.update_help_name)
|
||||
self.profile_description_label = HIGEntryLabel(_('Description'))
|
||||
@@ -193,13 +196,13 @@ class ProfileEditor(HIGWindow):
|
||||
# Buttons
|
||||
self.buttons_hbox = HIGHBox()
|
||||
|
||||
self.cancel_button = HIGButton(stock=gtk.STOCK_CANCEL)
|
||||
self.cancel_button = HIGButton(stock=Gtk.STOCK_CANCEL)
|
||||
self.cancel_button.connect('clicked', self.exit)
|
||||
|
||||
self.delete_button = HIGButton(stock=gtk.STOCK_DELETE)
|
||||
self.delete_button = HIGButton(stock=Gtk.STOCK_DELETE)
|
||||
self.delete_button.connect('clicked', self.delete_profile)
|
||||
|
||||
self.save_button = HIGButton(_("Save Changes"), stock=gtk.STOCK_SAVE)
|
||||
self.save_button = HIGButton(_("Save Changes"), stock=Gtk.STOCK_SAVE)
|
||||
self.save_button.connect('clicked', self.save_profile)
|
||||
|
||||
###
|
||||
@@ -228,7 +231,7 @@ class ProfileEditor(HIGWindow):
|
||||
self.middle_box._pack_expand_fill(self.help_vbox)
|
||||
|
||||
# Packing buttons to lower box
|
||||
self.lower_box.pack_end(self.buttons_hbox)
|
||||
self.lower_box.pack_end(self.buttons_hbox, True, True, 0)
|
||||
|
||||
# Packing the three vertical boxes to the main box
|
||||
self.main_whole_box._pack_noexpand_nofill(self.upper_box)
|
||||
@@ -238,7 +241,7 @@ class ProfileEditor(HIGWindow):
|
||||
|
||||
# Packing profile information tab on notebook
|
||||
self.notebook.append_page(
|
||||
self.profile_info_vbox, gtk.Label(_('Profile')))
|
||||
self.profile_info_vbox, Gtk.Label.new(_('Profile')))
|
||||
self.profile_info_vbox.set_border_width(5)
|
||||
table = HIGTable()
|
||||
self.profile_info_vbox._pack_noexpand_nofill(self.profile_info_label)
|
||||
@@ -292,7 +295,7 @@ class ProfileEditor(HIGWindow):
|
||||
else:
|
||||
hbox = tab.get_hmain_box()
|
||||
vbox.pack_start(hbox, True, True, 0)
|
||||
self.notebook.append_page(vbox, gtk.Label(tab_name))
|
||||
self.notebook.append_page(vbox, Gtk.Label.new(tab_name))
|
||||
|
||||
def save_profile(self, widget):
|
||||
if self.overwrite:
|
||||
@@ -314,7 +317,7 @@ class ProfileEditor(HIGWindow):
|
||||
|
||||
buf = self.profile_description_text.get_buffer()
|
||||
description = buf.get_text(
|
||||
buf.get_start_iter(), buf.get_end_iter())
|
||||
buf.get_start_iter(), buf.get_end_iter(), include_hidden_chars=True)
|
||||
|
||||
try:
|
||||
self.profile.add_profile(
|
||||
@@ -347,11 +350,11 @@ class ProfileEditor(HIGWindow):
|
||||
|
||||
def delete_profile(self, widget=None, extra=None):
|
||||
if self.deletable:
|
||||
dialog = HIGDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
|
||||
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
|
||||
dialog = HIGDialog(buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
|
||||
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
|
||||
alert = HIGEntryLabel('<b>' + _("Deleting Profile") + '</b>')
|
||||
text = HIGEntryLabel(_(
|
||||
'Your profile is going to be deleted! ClickOk to continue, '
|
||||
'Your profile is going to be deleted! Click Ok to continue, '
|
||||
'or Cancel to go back to Profile Editor.'))
|
||||
hbox = HIGHBox()
|
||||
hbox.set_border_width(5)
|
||||
@@ -361,21 +364,21 @@ class ProfileEditor(HIGWindow):
|
||||
vbox.set_border_width(5)
|
||||
vbox.set_spacing(12)
|
||||
|
||||
image = gtk.Image()
|
||||
image = Gtk.Image()
|
||||
image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
|
||||
Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
|
||||
|
||||
vbox.pack_start(alert)
|
||||
vbox.pack_start(text)
|
||||
hbox.pack_start(image)
|
||||
hbox.pack_start(vbox)
|
||||
vbox.pack_start(alert, True, True, 0)
|
||||
vbox.pack_start(text, True, True, 0)
|
||||
hbox.pack_start(image, True, True, 0)
|
||||
hbox.pack_start(vbox, True, True, 0)
|
||||
|
||||
dialog.vbox.pack_start(hbox)
|
||||
dialog.vbox.pack_start(hbox, True, True, 0)
|
||||
dialog.vbox.show_all()
|
||||
|
||||
response = dialog.run()
|
||||
dialog.destroy()
|
||||
if response == gtk.RESPONSE_CANCEL:
|
||||
if response == Gtk.ResponseType.CANCEL:
|
||||
return True
|
||||
self.profile.remove_profile(self.profile_name)
|
||||
|
||||
@@ -383,7 +386,7 @@ class ProfileEditor(HIGWindow):
|
||||
self.destroy()
|
||||
|
||||
def run_scan(self, widget=None):
|
||||
command_string = self.command_entry.get_text().decode("UTF-8")
|
||||
command_string = self.command_entry.get_text()
|
||||
self.scan_interface.command_toolbar.command = command_string
|
||||
self.scan_interface.start_scan_cb()
|
||||
self.exit()
|
||||
@@ -399,4 +402,4 @@ class ProfileEditor(HIGWindow):
|
||||
if __name__ == '__main__':
|
||||
p = ProfileEditor()
|
||||
p.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higexpanders import HIGExpander
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox, HIGHBox,\
|
||||
@@ -121,21 +123,21 @@ class HostDetails(HIGVBox):
|
||||
self.set_comment(host.comment)
|
||||
|
||||
def __create_widgets(self):
|
||||
self.host_status_expander = gtk.Expander(
|
||||
self.host_status_expander = Gtk.Expander.new(
|
||||
'<b>' + _('Host Status') + '</b>')
|
||||
self.address_expander = gtk.Expander('<b>' + _('Addresses') + '</b>')
|
||||
self.hostnames_expander = gtk.Expander('<b>' + _('Hostnames') + '</b>')
|
||||
self.os_expander = gtk.Expander('<b>' + _('Operating System') + '</b>')
|
||||
self.portsused_expander = gtk.Expander(
|
||||
self.address_expander = Gtk.Expander.new('<b>' + _('Addresses') + '</b>')
|
||||
self.hostnames_expander = Gtk.Expander.new('<b>' + _('Hostnames') + '</b>')
|
||||
self.os_expander = Gtk.Expander.new('<b>' + _('Operating System') + '</b>')
|
||||
self.portsused_expander = Gtk.Expander.new(
|
||||
'<b>' + _('Ports used') + '</b>')
|
||||
self.osclass_expander = gtk.Expander('<b>' + _('OS Classes') + '</b>')
|
||||
self.tcp_expander = gtk.Expander('<b>' + _('TCP Sequence') + '</b>')
|
||||
self.ip_expander = gtk.Expander('<b>' + _('IP ID Sequence') + '</b>')
|
||||
self.tcpts_expander = gtk.Expander(
|
||||
self.osclass_expander = Gtk.Expander.new('<b>' + _('OS Classes') + '</b>')
|
||||
self.tcp_expander = Gtk.Expander.new('<b>' + _('TCP Sequence') + '</b>')
|
||||
self.ip_expander = Gtk.Expander.new('<b>' + _('IP ID Sequence') + '</b>')
|
||||
self.tcpts_expander = Gtk.Expander.new(
|
||||
'<b>' + _('TCP TS Sequence') + '</b>')
|
||||
self.comment_expander = gtk.Expander('<b>' + _('Comments') + '</b>')
|
||||
self.os_image = gtk.Image()
|
||||
self.vulnerability_image = gtk.Image()
|
||||
self.comment_expander = Gtk.Expander.new('<b>' + _('Comments') + '</b>')
|
||||
self.os_image = Gtk.Image()
|
||||
self.vulnerability_image = Gtk.Image()
|
||||
|
||||
# Host Status expander
|
||||
self.host_state_label = HIGEntryLabel(_('State:'))
|
||||
@@ -235,9 +237,9 @@ class HostDetails(HIGVBox):
|
||||
table.attach(self.lastboot_label, 0, 1, 6, 7)
|
||||
table.attach(self.info_lastboot_label, 1, 2, 6, 7)
|
||||
|
||||
table.attach(self.os_image, 2, 4, 0, 3, xoptions=1, yoptions=0)
|
||||
table.attach(self.os_image, 2, 4, 0, 3, xoptions=Gtk.AttachOptions.EXPAND)
|
||||
table.attach(
|
||||
self.vulnerability_image, 2, 4, 4, 7, xoptions=1, yoptions=0)
|
||||
self.vulnerability_image, 2, 4, 4, 7, xoptions=Gtk.AttachOptions.EXPAND)
|
||||
|
||||
table.set_col_spacing(1, 50)
|
||||
|
||||
@@ -245,10 +247,10 @@ class HostDetails(HIGVBox):
|
||||
self._pack_noexpand_nofill(self.host_status_expander)
|
||||
|
||||
def set_os_image(self, image):
|
||||
self.os_image.set_from_stock(image, gtk.ICON_SIZE_DIALOG)
|
||||
self.os_image.set_from_stock(image, Gtk.IconSize.DIALOG)
|
||||
|
||||
def set_vulnerability_image(self, image):
|
||||
self.vulnerability_image.set_from_stock(image, gtk.ICON_SIZE_DIALOG)
|
||||
self.vulnerability_image.set_from_stock(image, Gtk.IconSize.DIALOG)
|
||||
|
||||
def set_addresses(self, address):
|
||||
self.address_expander.set_use_markup(True)
|
||||
@@ -306,7 +308,7 @@ class HostDetails(HIGVBox):
|
||||
self.os_expander.set_use_markup(True)
|
||||
self.os_expander.set_expanded(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
progress = gtk.ProgressBar()
|
||||
progress = Gtk.ProgressBar()
|
||||
|
||||
if 'accuracy' in os:
|
||||
progress.set_fraction(float(os['accuracy']) / 100.0)
|
||||
@@ -375,7 +377,7 @@ class HostDetails(HIGVBox):
|
||||
table.attach(HIGEntryLabel(o['osfamily']), 2, 3, y1, y2)
|
||||
table.attach(HIGEntryLabel(o['osgen']), 3, 4, y1, y2)
|
||||
|
||||
progress = gtk.ProgressBar()
|
||||
progress = Gtk.ProgressBar()
|
||||
progress.set_text(o['accuracy'] + '%')
|
||||
progress.set_fraction(float(o['accuracy']) / 100.0)
|
||||
table.attach(progress, 4, 5, y1, y2)
|
||||
@@ -389,7 +391,7 @@ class HostDetails(HIGVBox):
|
||||
self.tcp_expander.set_use_markup(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
for v in tcpseq['values'].split(','):
|
||||
combo.append_text(v)
|
||||
|
||||
@@ -410,7 +412,7 @@ class HostDetails(HIGVBox):
|
||||
self.ip_expander.set_use_markup(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
|
||||
for i in ipseq['values'].split(','):
|
||||
combo.append_text(i)
|
||||
@@ -429,7 +431,7 @@ class HostDetails(HIGVBox):
|
||||
self.tcpts_expander.set_use_markup(True)
|
||||
table, hbox = self.create_table_hbox()
|
||||
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
|
||||
for i in tcptsseq['values'].split(','):
|
||||
combo.append_text(i)
|
||||
@@ -450,13 +452,13 @@ class HostDetails(HIGVBox):
|
||||
|
||||
hbox = HIGHBox()
|
||||
|
||||
self.comment_scrolled = gtk.ScrolledWindow()
|
||||
self.comment_scrolled = Gtk.ScrolledWindow()
|
||||
self.comment_scrolled.set_border_width(5)
|
||||
self.comment_scrolled.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
self.comment_txt_vw = gtk.TextView()
|
||||
self.comment_txt_vw.set_wrap_mode(gtk.WRAP_WORD)
|
||||
self.comment_txt_vw = Gtk.TextView()
|
||||
self.comment_txt_vw.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
self.comment_txt_vw.get_buffer().set_text(comment)
|
||||
|
||||
self.comment_scrolled.add(self.comment_txt_vw)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
from zenmapGUI.Icons import get_os_icon
|
||||
@@ -71,14 +73,16 @@ def treemodel_get_addrs_for_sort(model, iter):
|
||||
|
||||
|
||||
# Used to sort hosts by address.
|
||||
def cmp_treemodel_addr(model, iter_a, iter_b):
|
||||
def cmp_treemodel_addr(model, iter_a, iter_b, *_):
|
||||
def cmp(a, b):
|
||||
return (a > b) - (a < b)
|
||||
addrs_a = treemodel_get_addrs_for_sort(model, iter_a)
|
||||
addrs_b = treemodel_get_addrs_for_sort(model, iter_b)
|
||||
return cmp(addrs_a, addrs_b)
|
||||
|
||||
|
||||
class ScanHostsView(HIGVBox, object):
|
||||
HOST_MODE, SERVICE_MODE = range(2)
|
||||
class ScanHostsView(HIGVBox):
|
||||
HOST_MODE, SERVICE_MODE = list(range(2))
|
||||
|
||||
def __init__(self, scan_interface):
|
||||
HIGVBox.__init__(self)
|
||||
@@ -103,31 +107,31 @@ class ScanHostsView(HIGVBox, object):
|
||||
|
||||
def _create_widgets(self):
|
||||
# Mode buttons
|
||||
self.host_mode_button = gtk.ToggleButton(_("Hosts"))
|
||||
self.service_mode_button = gtk.ToggleButton(_("Services"))
|
||||
self.buttons_box = gtk.HBox()
|
||||
self.host_mode_button = Gtk.ToggleButton.new_with_label(_("Hosts"))
|
||||
self.service_mode_button = Gtk.ToggleButton.new_with_label(_("Services"))
|
||||
self.buttons_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
|
||||
|
||||
# Main window vbox
|
||||
self.main_vbox = HIGVBox()
|
||||
|
||||
# Host list
|
||||
self.host_list = gtk.ListStore(object, str, str)
|
||||
self.host_list = Gtk.ListStore.new([object, str, str])
|
||||
self.host_list.set_sort_func(1000, cmp_treemodel_addr)
|
||||
self.host_list.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.host_view = gtk.TreeView(self.host_list)
|
||||
self.pic_column = gtk.TreeViewColumn(_('OS'))
|
||||
self.host_column = gtk.TreeViewColumn(_('Host'))
|
||||
self.os_cell = gtk.CellRendererPixbuf()
|
||||
self.host_cell = gtk.CellRendererText()
|
||||
self.host_list.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
self.host_view = Gtk.TreeView.new_with_model(self.host_list)
|
||||
self.pic_column = Gtk.TreeViewColumn(title=_('OS'))
|
||||
self.host_column = Gtk.TreeViewColumn(title=_('Host'))
|
||||
self.os_cell = Gtk.CellRendererPixbuf()
|
||||
self.host_cell = Gtk.CellRendererText()
|
||||
|
||||
# Service list
|
||||
self.service_list = gtk.ListStore(str)
|
||||
self.service_list.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||
self.service_view = gtk.TreeView(self.service_list)
|
||||
self.service_column = gtk.TreeViewColumn(_('Service'))
|
||||
self.service_cell = gtk.CellRendererText()
|
||||
self.service_list = Gtk.ListStore.new([str])
|
||||
self.service_list.set_sort_column_id(0, Gtk.SortType.ASCENDING)
|
||||
self.service_view = Gtk.TreeView.new_with_model(self.service_list)
|
||||
self.service_column = Gtk.TreeViewColumn(title=_('Service'))
|
||||
self.service_cell = Gtk.CellRendererText()
|
||||
|
||||
self.scrolled = gtk.ScrolledWindow()
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.main_vbox.set_spacing(0)
|
||||
@@ -138,8 +142,8 @@ class ScanHostsView(HIGVBox, object):
|
||||
self.host_mode_button.set_active(True)
|
||||
|
||||
self.buttons_box.set_border_width(5)
|
||||
self.buttons_box.pack_start(self.host_mode_button)
|
||||
self.buttons_box.pack_start(self.service_mode_button)
|
||||
self.buttons_box.pack_start(self.host_mode_button, True, True, 0)
|
||||
self.buttons_box.pack_start(self.service_mode_button, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.host_mode_button.connect("toggled", self.host_mode)
|
||||
@@ -173,14 +177,14 @@ class ScanHostsView(HIGVBox, object):
|
||||
def _set_scrolled(self):
|
||||
self.scrolled.set_border_width(5)
|
||||
self.scrolled.set_size_request(150, -1)
|
||||
self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def _set_service_list(self):
|
||||
self.service_view.set_enable_search(True)
|
||||
self.service_view.set_search_column(0)
|
||||
|
||||
selection = self.service_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
self.service_view.append_column(self.service_column)
|
||||
|
||||
self.service_column.set_resizable(True)
|
||||
@@ -194,7 +198,7 @@ class ScanHostsView(HIGVBox, object):
|
||||
self.host_view.set_search_column(1)
|
||||
|
||||
selection = self.host_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
self.host_view.append_column(self.pic_column)
|
||||
self.host_view.append_column(self.host_column)
|
||||
@@ -228,7 +232,7 @@ class ScanHostsView(HIGVBox, object):
|
||||
# Treeview?"
|
||||
sort_column_id = self.host_list.get_sort_column_id()
|
||||
self.host_list.set_default_sort_func(lambda *args: -1)
|
||||
self.host_list.set_sort_column_id(-1, gtk.SORT_ASCENDING)
|
||||
self.host_list.set_sort_column_id(-1, Gtk.SortType.ASCENDING)
|
||||
self.host_view.freeze_child_notify()
|
||||
self.host_view.set_model(None)
|
||||
|
||||
@@ -275,8 +279,10 @@ class ScanHostsView(HIGVBox, object):
|
||||
self.service_list.append([service])
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
h = ScanHostsView(None)
|
||||
w.add(h)
|
||||
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,9 +57,12 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
import errno
|
||||
import gtk
|
||||
import gobject
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
@@ -220,19 +222,19 @@ class ScanInterface(HIGVBox):
|
||||
def filter_changed(self, filter_bar):
|
||||
# Restart the timer to start the filter.
|
||||
if self.filter_timeout_id:
|
||||
gobject.source_remove(self.filter_timeout_id)
|
||||
self.filter_timeout_id = gobject.timeout_add(
|
||||
GLib.source_remove(self.filter_timeout_id)
|
||||
self.filter_timeout_id = GLib.timeout_add(
|
||||
self.FILTER_DELAY, self.filter_hosts,
|
||||
filter_bar.get_filter_string())
|
||||
|
||||
def filter_hosts(self, filter_string):
|
||||
start = time.clock()
|
||||
start = time.perf_counter()
|
||||
self.inventory.apply_filter(filter_string)
|
||||
filter_time = time.clock() - start
|
||||
filter_time = time.perf_counter() - start
|
||||
# Update the gui
|
||||
start = time.clock()
|
||||
start = time.perf_counter()
|
||||
self.update_ui()
|
||||
gui_time = time.clock() - start
|
||||
gui_time = time.perf_counter() - start
|
||||
|
||||
if filter_time + gui_time > 0.0:
|
||||
log.debug("apply_filter %g ms update_ui %g ms (%.0f%% filter)" %
|
||||
@@ -368,7 +370,7 @@ class ScanInterface(HIGVBox):
|
||||
if target != '':
|
||||
try:
|
||||
self.toolbar.add_new_target(target)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
# We failed to save target_list.txt; treat it as read-only.
|
||||
# Probably it's owned by root and this is a normal user.
|
||||
log.debug(">>> Error saving %s: %s" % (
|
||||
@@ -381,7 +383,7 @@ class ScanInterface(HIGVBox):
|
||||
"Maybe the selected/typed profile doesn't exist. "
|
||||
"Please check the profile name or type the nmap "
|
||||
"command you would like to execute."),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
@@ -431,7 +433,7 @@ class ScanInterface(HIGVBox):
|
||||
pass
|
||||
# Create TreeRowReferences because those persist while we change
|
||||
# the model.
|
||||
selected_refs.append(gtk.TreeRowReference(model, path))
|
||||
selected_refs.append(Gtk.TreeRowReference.new(model, path))
|
||||
# Delete the entries from the ScansListStore.
|
||||
for ref in selected_refs:
|
||||
model.remove(model.get_iter(ref.get_path()))
|
||||
@@ -463,11 +465,11 @@ class ScanInterface(HIGVBox):
|
||||
completion."""
|
||||
try:
|
||||
command_execution = NmapCommand(command)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Error building command"),
|
||||
secondary_text=_("Error message: %s") % str(e),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
@@ -475,8 +477,8 @@ class ScanInterface(HIGVBox):
|
||||
|
||||
try:
|
||||
command_execution.run_scan()
|
||||
except OSError, e:
|
||||
text = unicode(e.strerror, errors='replace')
|
||||
except OSError as e:
|
||||
text = str(e.strerror, errors='replace')
|
||||
# Handle ENOENT specially.
|
||||
if e.errno == errno.ENOENT:
|
||||
# nmap_command_path comes from zenmapCore.NmapCommand.
|
||||
@@ -488,7 +490,7 @@ class ScanInterface(HIGVBox):
|
||||
if fsencoding:
|
||||
path_env = path_env.decode(fsencoding, 'replace')
|
||||
default_paths = path_env.split(os.pathsep)
|
||||
text += u"\n\n{}\n\n{}".format(
|
||||
text += "\n\n{}\n\n{}".format(
|
||||
_("This means that the nmap executable was "
|
||||
"not found in your system PATH, which is"),
|
||||
path_env or _("<undefined>")
|
||||
@@ -498,23 +500,23 @@ class ScanInterface(HIGVBox):
|
||||
p not in default_paths)]
|
||||
if len(extra_paths) > 0:
|
||||
if len(extra_paths) == 1:
|
||||
text += u"\n\n" + _("plus the extra directory")
|
||||
text += "\n\n" + _("plus the extra directory")
|
||||
else:
|
||||
text += u"\n\n" + _("plus the extra directories")
|
||||
text += u"\n\n" + os.pathsep.join(extra_paths)
|
||||
text += "\n\n" + _("plus the extra directories")
|
||||
text += "\n\n" + os.pathsep.join(extra_paths)
|
||||
else:
|
||||
text += u" (%d)" % e.errno
|
||||
text += " (%d)" % e.errno
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Error executing command"),
|
||||
secondary_text=text, type=gtk.MESSAGE_ERROR)
|
||||
secondary_text=text, type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Error executing command"),
|
||||
secondary_text=unicode(str(e), errors='replace'),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
secondary_text=str(e),
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
return
|
||||
@@ -530,7 +532,7 @@ class ScanInterface(HIGVBox):
|
||||
self.scan_result.refresh_nmap_output()
|
||||
|
||||
# Add a timeout function
|
||||
self.verify_thread_timeout_id = gobject.timeout_add(
|
||||
self.verify_thread_timeout_id = GLib.timeout_add(
|
||||
NMAP_OUTPUT_REFRESH_INTERVAL, self.verify_execution)
|
||||
|
||||
def verify_execution(self):
|
||||
@@ -569,12 +571,12 @@ class ScanInterface(HIGVBox):
|
||||
parsed = NmapParser()
|
||||
try:
|
||||
parsed.parse_file(command.get_xml_output_filename())
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
# It's possible to run Nmap without generating an XML output file,
|
||||
# like with "nmap -V".
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
except xml.sax.SAXParseException, e:
|
||||
except xml.sax.SAXParseException as e:
|
||||
try:
|
||||
# Some options like --iflist cause Nmap to emit an empty XML
|
||||
# file. Ignore the exception in this case.
|
||||
@@ -587,7 +589,7 @@ class ScanInterface(HIGVBox):
|
||||
secondary_text=_(
|
||||
"There was an error while parsing the XML file "
|
||||
"generated from the scan:\n\n%s""") % str(e),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
else:
|
||||
@@ -596,13 +598,13 @@ class ScanInterface(HIGVBox):
|
||||
self.scan_result.refresh_nmap_output()
|
||||
try:
|
||||
self.inventory.add_scan(parsed)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
warn_dialog = HIGAlertDialog(
|
||||
message_format=_("Cannot merge scan"),
|
||||
secondary_text=_(
|
||||
"There was an error while merging the new scan's "
|
||||
"XML:\n\n%s") % str(e),
|
||||
type=gtk.MESSAGE_ERROR)
|
||||
type=Gtk.MessageType.ERROR)
|
||||
warn_dialog.run()
|
||||
warn_dialog.destroy()
|
||||
parsed.set_xml_is_temp(command.xml_is_temp)
|
||||
@@ -864,20 +866,20 @@ class ScanInterface(HIGVBox):
|
||||
host_page.thaw()
|
||||
|
||||
|
||||
class ScanResult(gtk.HPaned):
|
||||
class ScanResult(Gtk.Paned):
|
||||
"""This is the pane that has the "Host"/"Service" column (ScanHostsView) on
|
||||
the left and the "Nmap Output"/"Ports / Hosts"/etc. (ScanResultNotebook) on
|
||||
the right. It's the part of the interface below the toolbar."""
|
||||
def __init__(self, inventory, scans_store, scan_interface=None):
|
||||
gtk.HPaned.__init__(self)
|
||||
Gtk.Paned.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.scan_host_view = ScanHostsView(scan_interface)
|
||||
self.scan_result_notebook = ScanResultNotebook(inventory, scans_store)
|
||||
self.filter_toggle_button = gtk.ToggleButton(_("Filter Hosts"))
|
||||
self.filter_toggle_button = Gtk.ToggleButton.new_with_label(_("Filter Hosts"))
|
||||
|
||||
vbox = gtk.VBox()
|
||||
vbox.pack_start(self.scan_host_view, True, True)
|
||||
vbox.pack_start(self.filter_toggle_button, False)
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
vbox.pack_start(self.scan_host_view, True, True, 0)
|
||||
vbox.pack_start(self.filter_toggle_button, False, True, 0)
|
||||
self.pack1(vbox)
|
||||
self.pack2(self.scan_result_notebook, True, False)
|
||||
|
||||
@@ -923,11 +925,11 @@ class ScanResultNotebook(HIGNotebook):
|
||||
self.scans_list.scans_list.connect(
|
||||
"row-activated", self._scan_row_activated)
|
||||
|
||||
self.append_page(self.nmap_output_page, gtk.Label(_('Nmap Output')))
|
||||
self.append_page(self.open_ports_page, gtk.Label(_('Ports / Hosts')))
|
||||
self.append_page(self.topology_page, gtk.Label(_('Topology')))
|
||||
self.append_page(self.host_details_page, gtk.Label(_('Host Details')))
|
||||
self.append_page(self.scans_list_page, gtk.Label(_('Scans')))
|
||||
self.append_page(self.nmap_output_page, Gtk.Label.new(_('Nmap Output')))
|
||||
self.append_page(self.open_ports_page, Gtk.Label.new(_('Ports / Hosts')))
|
||||
self.append_page(self.topology_page, Gtk.Label.new(_('Topology')))
|
||||
self.append_page(self.host_details_page, Gtk.Label.new(_('Host Details')))
|
||||
self.append_page(self.scans_list_page, Gtk.Label.new(_('Scans')))
|
||||
|
||||
def host_mode(self):
|
||||
self.open_ports.host.host_mode()
|
||||
@@ -948,7 +950,7 @@ class ScanResultNotebook(HIGNotebook):
|
||||
self.topology = TopologyPage(inventory)
|
||||
self.scans_list = ScanScanListPage(scans_store)
|
||||
|
||||
self.no_selected = gtk.Label(_('No host selected.'))
|
||||
self.no_selected = Gtk.Label.new(_('No host selected.'))
|
||||
self.host_details = self.no_selected
|
||||
|
||||
self.open_ports_page.add(self.open_ports)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,9 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject, GdkPixbuf, Pango
|
||||
|
||||
import os
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox, HIGVBox
|
||||
@@ -74,14 +75,14 @@ import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
def scan_entry_data_func(widget, cell_renderer, model, iter):
|
||||
"""Set the properties of a cell renderer for a scan entry."""
|
||||
cell_renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
|
||||
cell_renderer.set_property("style", pango.STYLE_NORMAL)
|
||||
cell_renderer.set_property("ellipsize", Pango.EllipsizeMode.END)
|
||||
cell_renderer.set_property("style", Pango.Style.NORMAL)
|
||||
cell_renderer.set_property("strikethrough", False)
|
||||
entry = model.get_value(iter, 0)
|
||||
if entry is None:
|
||||
return
|
||||
if entry.running:
|
||||
cell_renderer.set_property("style", pango.STYLE_ITALIC)
|
||||
cell_renderer.set_property("style", Pango.Style.ITALIC)
|
||||
elif entry.finished:
|
||||
pass
|
||||
elif entry.failed or entry.canceled:
|
||||
@@ -89,21 +90,21 @@ def scan_entry_data_func(widget, cell_renderer, model, iter):
|
||||
cell_renderer.set_property("text", entry.get_command_string())
|
||||
|
||||
|
||||
class Throbber(gtk.Image):
|
||||
class Throbber(Gtk.Image):
|
||||
"""This is a little progress indicator that animates while a scan is
|
||||
running."""
|
||||
try:
|
||||
still = gtk.gdk.pixbuf_new_from_file(
|
||||
still = GdkPixbuf.Pixbuf.new_from_file(
|
||||
os.path.join(Path.pixmaps_dir, "throbber.png"))
|
||||
anim = gtk.gdk.PixbufAnimation(
|
||||
anim = GdkPixbuf.PixbufAnimation(
|
||||
os.path.join(Path.pixmaps_dir, "throbber.gif"))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
log.debug("Error loading throbber images: %s." % str(e))
|
||||
still = None
|
||||
anim = None
|
||||
|
||||
def __init__(self):
|
||||
gtk.Image.__init__(self)
|
||||
Gtk.Image.__init__(self)
|
||||
self.set_from_pixbuf(self.still)
|
||||
self.animating = False
|
||||
|
||||
@@ -127,7 +128,7 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
the combo box selection changes."""
|
||||
|
||||
__gsignals__ = {
|
||||
"changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
|
||||
"changed": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, scans_store):
|
||||
@@ -140,8 +141,8 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
|
||||
hbox = HIGHBox()
|
||||
|
||||
self.scans_list = gtk.ComboBox(scans_store)
|
||||
cell = gtk.CellRendererText()
|
||||
self.scans_list = Gtk.ComboBox.new_with_model(scans_store)
|
||||
cell = Gtk.CellRendererText()
|
||||
self.scans_list.pack_start(cell, True)
|
||||
self.scans_list.set_cell_data_func(cell, scan_entry_data_func)
|
||||
hbox._pack_expand_fill(self.scans_list)
|
||||
@@ -153,7 +154,7 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
self.throbber = Throbber()
|
||||
hbox._pack_noexpand_nofill(self.throbber)
|
||||
|
||||
self.details_button = gtk.Button(_("Details"))
|
||||
self.details_button = Gtk.Button.new_with_label(_("Details"))
|
||||
self.details_button.connect("clicked", self._show_details)
|
||||
hbox._pack_noexpand_nofill(self.details_button)
|
||||
|
||||
@@ -227,7 +228,7 @@ class ScanNmapOutputPage(HIGVBox):
|
||||
if not entry.finished:
|
||||
return
|
||||
if self._details_windows.get(entry) is None:
|
||||
window = gtk.Window()
|
||||
window = Gtk.Window()
|
||||
window.add(ScanRunDetailsPage(entry.parsed))
|
||||
|
||||
def close_details(details, event, entry):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
|
||||
@@ -68,9 +70,9 @@ import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
def findout_service_icon(port_info):
|
||||
if port_info["port_state"] in ["open", "open|filtered"]:
|
||||
return gtk.STOCK_YES
|
||||
return Gtk.STOCK_YES
|
||||
else:
|
||||
return gtk.STOCK_NO
|
||||
return Gtk.STOCK_NO
|
||||
|
||||
|
||||
def get_version_string(d):
|
||||
@@ -90,42 +92,44 @@ def get_version_string(d):
|
||||
|
||||
def get_addrs(host):
|
||||
if host is None:
|
||||
return None
|
||||
return []
|
||||
return host.get_addrs_for_sort()
|
||||
|
||||
|
||||
def cmp_addrs(host_a, host_b):
|
||||
def cmp(a, b):
|
||||
return (a > b) - (a < b)
|
||||
return cmp(get_addrs(host_a), get_addrs(host_b))
|
||||
|
||||
|
||||
def cmp_port_list_addr(model, iter_a, iter_b):
|
||||
def cmp_port_list_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 0)
|
||||
host_b = model.get_value(iter_b, 0)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
def cmp_port_tree_addr(model, iter_a, iter_b):
|
||||
def cmp_port_tree_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 0)
|
||||
host_b = model.get_value(iter_b, 0)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
def cmp_host_list_addr(model, iter_a, iter_b):
|
||||
def cmp_host_list_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 2)
|
||||
host_b = model.get_value(iter_b, 2)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
def cmp_host_tree_addr(model, iter_a, iter_b):
|
||||
def cmp_host_tree_addr(model, iter_a, iter_b, *_):
|
||||
host_a = model.get_value(iter_a, 2)
|
||||
host_b = model.get_value(iter_b, 2)
|
||||
return cmp_addrs(host_a, host_b)
|
||||
|
||||
|
||||
class ScanOpenPortsPage(gtk.ScrolledWindow):
|
||||
class ScanOpenPortsPage(Gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
self.__create_widgets()
|
||||
|
||||
@@ -150,65 +154,65 @@ class HostOpenPorts(HIGVBox):
|
||||
# host hostname icon port protocol state service version
|
||||
# The hostname column is shown only when more than one host is selected
|
||||
# (hence port_tree not port_list is used).
|
||||
self.port_list = gtk.ListStore(
|
||||
object, str, str, int, str, str, str, str)
|
||||
self.port_tree = gtk.TreeStore(
|
||||
object, str, str, int, str, str, str, str)
|
||||
self.port_list = Gtk.ListStore.new([
|
||||
object, str, str, int, str, str, str, str])
|
||||
self.port_tree = Gtk.TreeStore.new([
|
||||
object, str, str, int, str, str, str, str])
|
||||
|
||||
self.port_list.set_sort_func(1000, cmp_port_list_addr)
|
||||
self.port_list.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.port_list.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
self.port_tree.set_sort_func(1000, cmp_port_tree_addr)
|
||||
self.port_tree.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.port_tree.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
|
||||
self.port_view = gtk.TreeView(self.port_list)
|
||||
self.port_view = Gtk.TreeView.new_with_model(self.port_list)
|
||||
|
||||
self.cell_icon = gtk.CellRendererPixbuf()
|
||||
self.cell_port = gtk.CellRendererText()
|
||||
self.cell_icon = Gtk.CellRendererPixbuf()
|
||||
self.cell_port = Gtk.CellRendererText()
|
||||
|
||||
self.port_columns['hostname'] = gtk.TreeViewColumn(_('Host'))
|
||||
self.port_columns['icon'] = gtk.TreeViewColumn('')
|
||||
self.port_columns['port_number'] = gtk.TreeViewColumn(_('Port'))
|
||||
self.port_columns['protocol'] = gtk.TreeViewColumn(_('Protocol'))
|
||||
self.port_columns['state'] = gtk.TreeViewColumn(_('State'))
|
||||
self.port_columns['service'] = gtk.TreeViewColumn(_('Service'))
|
||||
self.port_columns['version'] = gtk.TreeViewColumn(_('Version'))
|
||||
self.port_columns['hostname'] = Gtk.TreeViewColumn(title=_('Host'))
|
||||
self.port_columns['icon'] = Gtk.TreeViewColumn(title='')
|
||||
self.port_columns['port_number'] = Gtk.TreeViewColumn(title=_('Port'))
|
||||
self.port_columns['protocol'] = Gtk.TreeViewColumn(title=_('Protocol'))
|
||||
self.port_columns['state'] = Gtk.TreeViewColumn(title=_('State'))
|
||||
self.port_columns['service'] = Gtk.TreeViewColumn(title=_('Service'))
|
||||
self.port_columns['version'] = Gtk.TreeViewColumn(title=_('Version'))
|
||||
|
||||
# Host services view
|
||||
self.host_columns = {}
|
||||
# service icon host hostname port protocol state version
|
||||
# service is shown only when more than one service is selected (hence
|
||||
# host_tree not host_list is used).
|
||||
self.host_list = gtk.ListStore(
|
||||
str, str, object, str, int, str, str, str)
|
||||
self.host_tree = gtk.TreeStore(
|
||||
str, str, object, str, int, str, str, str)
|
||||
self.host_list = Gtk.ListStore.new([
|
||||
str, str, object, str, int, str, str, str])
|
||||
self.host_tree = Gtk.TreeStore.new([
|
||||
str, str, object, str, int, str, str, str])
|
||||
|
||||
self.host_list.set_sort_func(1000, cmp_host_list_addr)
|
||||
self.host_list.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.host_list.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
self.host_tree.set_sort_func(1000, cmp_host_tree_addr)
|
||||
self.host_tree.set_sort_column_id(1000, gtk.SORT_ASCENDING)
|
||||
self.host_tree.set_sort_column_id(1000, Gtk.SortType.ASCENDING)
|
||||
|
||||
self.host_view = gtk.TreeView(self.host_list)
|
||||
self.host_view = Gtk.TreeView.new_with_model(self.host_list)
|
||||
|
||||
self.cell_host_icon = gtk.CellRendererPixbuf()
|
||||
self.cell_host = gtk.CellRendererText()
|
||||
self.cell_host_icon = Gtk.CellRendererPixbuf()
|
||||
self.cell_host = Gtk.CellRendererText()
|
||||
|
||||
self.host_columns['service'] = gtk.TreeViewColumn(_('Service'))
|
||||
self.host_columns['icon'] = gtk.TreeViewColumn('')
|
||||
self.host_columns['hostname'] = gtk.TreeViewColumn(_('Hostname'))
|
||||
self.host_columns['protocol'] = gtk.TreeViewColumn(_('Protocol'))
|
||||
self.host_columns['port_number'] = gtk.TreeViewColumn(_('Port'))
|
||||
self.host_columns['state'] = gtk.TreeViewColumn(_('State'))
|
||||
self.host_columns['version'] = gtk.TreeViewColumn(_('Version'))
|
||||
self.host_columns['service'] = Gtk.TreeViewColumn(title=_('Service'))
|
||||
self.host_columns['icon'] = Gtk.TreeViewColumn(title='')
|
||||
self.host_columns['hostname'] = Gtk.TreeViewColumn(title=_('Hostname'))
|
||||
self.host_columns['protocol'] = Gtk.TreeViewColumn(title=_('Protocol'))
|
||||
self.host_columns['port_number'] = Gtk.TreeViewColumn(title=_('Port'))
|
||||
self.host_columns['state'] = Gtk.TreeViewColumn(title=_('State'))
|
||||
self.host_columns['version'] = Gtk.TreeViewColumn(title=_('Version'))
|
||||
|
||||
self.scroll_ports_hosts = gtk.ScrolledWindow()
|
||||
self.scroll_ports_hosts = Gtk.ScrolledWindow()
|
||||
|
||||
def _set_host_list(self):
|
||||
self.host_view.set_enable_search(True)
|
||||
self.host_view.set_search_column(2)
|
||||
|
||||
selection = self.host_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
columns = ["service", "icon", "hostname", "port_number",
|
||||
"protocol", "state", "version"]
|
||||
@@ -247,14 +251,14 @@ class HostOpenPorts(HIGVBox):
|
||||
self.host_columns['service'].set_visible(False)
|
||||
|
||||
self.scroll_ports_hosts.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def _set_port_list(self):
|
||||
self.port_view.set_enable_search(True)
|
||||
self.port_view.set_search_column(3)
|
||||
|
||||
selection = self.port_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
self.port_view.append_column(self.port_columns['hostname'])
|
||||
self.port_view.append_column(self.port_columns['icon'])
|
||||
@@ -297,7 +301,7 @@ class HostOpenPorts(HIGVBox):
|
||||
self.port_columns['hostname'].set_visible(False)
|
||||
|
||||
self.scroll_ports_hosts.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
def port_mode(self):
|
||||
child = self.scroll_ports_hosts.get_child()
|
||||
@@ -425,28 +429,29 @@ class HostOpenPorts(HIGVBox):
|
||||
|
||||
def clear_port_list(self):
|
||||
for i in range(len(self.port_list)):
|
||||
iter = self.port_list.get_iter_root()
|
||||
iter = self.port_list.get_iter_first()
|
||||
del(self.port_list[iter])
|
||||
|
||||
def clear_host_list(self):
|
||||
for i in range(len(self.host_list)):
|
||||
iter = self.host_list.get_iter_root()
|
||||
iter = self.host_list.get_iter_first()
|
||||
del(self.host_list[iter])
|
||||
|
||||
def clear_port_tree(self):
|
||||
for i in range(len(self.port_tree)):
|
||||
iter = self.port_tree.get_iter_root()
|
||||
iter = self.port_tree.get_iter_first()
|
||||
del(self.port_tree[iter])
|
||||
|
||||
def clear_host_tree(self):
|
||||
for i in range(len(self.host_tree)):
|
||||
iter = self.host_tree.get_iter_root()
|
||||
iter = self.host_tree.get_iter_first()
|
||||
del(self.host_tree[iter])
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
h = HostOpenPorts()
|
||||
w.add(h)
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox, HIGHBox,\
|
||||
hig_box_space_holder
|
||||
from zenmapGUI.higwidgets.higtables import HIGTable
|
||||
@@ -86,7 +89,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
self.debug_label = HIGEntryLabel(_('Debug level:'))
|
||||
self.info_debug_label = HIGEntryLabel(na)
|
||||
|
||||
self.command_expander = gtk.Expander(
|
||||
self.command_expander = Gtk.Expander.new(
|
||||
"<b>" + _("Command Info") + "</b>")
|
||||
self.command_expander.set_use_markup(True)
|
||||
|
||||
@@ -140,7 +143,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
self.closed_label = HIGEntryLabel(_('Closed ports:'))
|
||||
self.info_closed_label = HIGEntryLabel(na)
|
||||
|
||||
self.general_expander = gtk.Expander(
|
||||
self.general_expander = Gtk.Expander.new(
|
||||
"<b>" + _("General Info") + "</b>")
|
||||
self.general_expander.set_use_markup(True)
|
||||
|
||||
@@ -202,7 +205,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
self.info_closed_label.set_text(str(scan.get_closed_ports()))
|
||||
|
||||
for scaninfo in scan.get_scaninfo():
|
||||
exp = gtk.Expander('<b>%s - %s</b>' % (
|
||||
exp = Gtk.Expander.new('<b>%s - %s</b>' % (
|
||||
_('Scan Info'), scaninfo['type'].capitalize()))
|
||||
exp.set_use_markup(True)
|
||||
|
||||
@@ -241,7 +244,7 @@ class ScanRunDetailsPage(HIGVBox):
|
||||
def make_services_display(self, services):
|
||||
"""Return a widget displaying a list of services like
|
||||
1-1027,1029-1033,1040,1043,1050,1058-1059,1067-1068,1076,1080"""
|
||||
combo = gtk.combo_box_new_text()
|
||||
combo = Gtk.ComboBoxText()
|
||||
|
||||
for i in services.split(","):
|
||||
combo.append_text(i)
|
||||
@@ -256,8 +259,8 @@ if __name__ == "__main__":
|
||||
parsed = NmapParser()
|
||||
parsed.parse_file(filename)
|
||||
run_details = ScanRunDetailsPage(parsed)
|
||||
window = gtk.Window()
|
||||
window = Gtk.Window()
|
||||
window.add(run_details)
|
||||
window.connect("delete-event", lambda *args: gtk.main_quit())
|
||||
window.connect("delete-event", lambda *args: Gtk.main_quit())
|
||||
window.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,8 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Pango
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox, HIGVBox
|
||||
from zenmapGUI.higwidgets.higbuttons import HIGButton
|
||||
@@ -67,7 +68,7 @@ from zenmapGUI.higwidgets.higscrollers import HIGScrolledWindow
|
||||
import zenmapCore.I18N # lgtm[py/unused-import]
|
||||
|
||||
|
||||
def status_data_func(widget, cell_renderer, model, iter):
|
||||
def status_data_func(widget, cell_renderer, model, iter, data):
|
||||
entry = model.get_value(iter, 0)
|
||||
if entry.running:
|
||||
status = _("Running")
|
||||
@@ -83,9 +84,9 @@ def status_data_func(widget, cell_renderer, model, iter):
|
||||
cell_renderer.set_property("text", status)
|
||||
|
||||
|
||||
def command_data_func(widget, cell_renderer, model, iter):
|
||||
def command_data_func(widget, cell_renderer, model, iter, data):
|
||||
entry = model.get_value(iter, 0)
|
||||
cell_renderer.set_property("ellipsize", pango.ELLIPSIZE_END)
|
||||
cell_renderer.set_property("ellipsize", Pango.EllipsizeMode.END)
|
||||
cell_renderer.set_property("text", entry.get_command_string())
|
||||
|
||||
|
||||
@@ -100,19 +101,19 @@ class ScanScanListPage(HIGVBox):
|
||||
|
||||
scans_store.connect("row-changed", self._row_changed)
|
||||
|
||||
self.scans_list = gtk.TreeView(scans_store)
|
||||
self.scans_list = Gtk.TreeView.new_with_model(scans_store)
|
||||
self.scans_list.get_selection().connect(
|
||||
"changed", self._selection_changed)
|
||||
|
||||
status_col = gtk.TreeViewColumn(_("Status"))
|
||||
cell = gtk.CellRendererText()
|
||||
status_col.pack_start(cell)
|
||||
status_col = Gtk.TreeViewColumn(title=_("Status"))
|
||||
cell = Gtk.CellRendererText()
|
||||
status_col.pack_start(cell, True)
|
||||
status_col.set_cell_data_func(cell, status_data_func)
|
||||
self.scans_list.append_column(status_col)
|
||||
|
||||
command_col = gtk.TreeViewColumn(_("Command"))
|
||||
cell = gtk.CellRendererText()
|
||||
command_col.pack_start(cell)
|
||||
command_col = Gtk.TreeViewColumn(title=_("Command"))
|
||||
cell = Gtk.CellRendererText()
|
||||
command_col.pack_start(cell, True)
|
||||
command_col.set_cell_data_func(cell, command_data_func)
|
||||
self.scans_list.append_column(command_col)
|
||||
|
||||
@@ -120,25 +121,25 @@ class ScanScanListPage(HIGVBox):
|
||||
scrolled_window.set_border_width(0)
|
||||
scrolled_window.add(self.scans_list)
|
||||
|
||||
self.pack_start(scrolled_window, True, True)
|
||||
self.pack_start(scrolled_window, True, True, 0)
|
||||
|
||||
hbox = HIGHBox()
|
||||
buttonbox = gtk.HButtonBox()
|
||||
buttonbox.set_layout(gtk.BUTTONBOX_START)
|
||||
buttonbox = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
buttonbox.set_layout(Gtk.ButtonBoxStyle.START)
|
||||
buttonbox.set_spacing(4)
|
||||
|
||||
self.append_button = HIGButton(_("Append Scan"), gtk.STOCK_ADD)
|
||||
buttonbox.pack_start(self.append_button, False)
|
||||
self.append_button = HIGButton(_("Append Scan"), Gtk.STOCK_ADD)
|
||||
buttonbox.pack_start(self.append_button, False, True, 0)
|
||||
|
||||
self.remove_button = HIGButton(_("Remove Scan"), gtk.STOCK_REMOVE)
|
||||
buttonbox.pack_start(self.remove_button, False)
|
||||
self.remove_button = HIGButton(_("Remove Scan"), Gtk.STOCK_REMOVE)
|
||||
buttonbox.pack_start(self.remove_button, False, True, 0)
|
||||
|
||||
self.cancel_button = HIGButton(_("Cancel Scan"), gtk.STOCK_CANCEL)
|
||||
buttonbox.pack_start(self.cancel_button, False)
|
||||
self.cancel_button = HIGButton(_("Cancel Scan"), Gtk.STOCK_CANCEL)
|
||||
buttonbox.pack_start(self.cancel_button, False, True, 0)
|
||||
|
||||
hbox.pack_start(buttonbox, padding=4)
|
||||
hbox.pack_start(buttonbox, True, True, 4)
|
||||
|
||||
self.pack_start(hbox, False, padding=4)
|
||||
self.pack_start(hbox, False, True, 4)
|
||||
|
||||
self._update()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGHBox
|
||||
from zenmapGUI.higwidgets.higlabels import HIGEntryLabel
|
||||
@@ -77,14 +79,14 @@ class ScanCommandToolbar(HIGHBox):
|
||||
HIGHBox.__init__(self)
|
||||
|
||||
self.command_label = HIGEntryLabel(_("Command:"))
|
||||
self.command_entry = gtk.Entry()
|
||||
self.command_entry = Gtk.Entry()
|
||||
|
||||
self._pack_noexpand_nofill(self.command_label)
|
||||
self._pack_expand_fill(self.command_entry)
|
||||
|
||||
def get_command(self):
|
||||
"""Retrieve command entry"""
|
||||
return self.command_entry.get_text().decode("UTF-8")
|
||||
return self.command_entry.get_text()
|
||||
|
||||
def set_command(self, command):
|
||||
"""Set a command entry"""
|
||||
@@ -108,10 +110,8 @@ class ScanToolbar(HIGHBox):
|
||||
self._create_target()
|
||||
self._create_profile()
|
||||
|
||||
self.scan_button = gtk.Button(_("Scan"))
|
||||
#self.scan_button = HIGButton(_("Scan "), gtk.STOCK_MEDIA_PLAY)
|
||||
self.cancel_button = gtk.Button(_("Cancel"))
|
||||
#self.cancel_button = HIGButton(_("Cancel "), gtk.STOCK_CANCEL)
|
||||
self.scan_button = Gtk.Button.new_with_label(_("Scan"))
|
||||
self.cancel_button = Gtk.Button.new_with_label(_("Cancel"))
|
||||
|
||||
self._pack_noexpand_nofill(self.target_label)
|
||||
self._pack_expand_fill(self.target_entry)
|
||||
@@ -123,11 +123,11 @@ class ScanToolbar(HIGHBox):
|
||||
self._pack_noexpand_nofill(self.cancel_button)
|
||||
|
||||
# Skip over the dropdown arrow so you can tab to the profile entry.
|
||||
self.target_entry.set_focus_chain((self.target_entry.child,))
|
||||
self.target_entry.set_focus_chain((self.target_entry.get_child(),))
|
||||
|
||||
self.target_entry.child.connect('activate',
|
||||
self.target_entry.get_child().connect('activate',
|
||||
lambda x: self.profile_entry.grab_focus())
|
||||
self.profile_entry.child.connect('activate',
|
||||
self.profile_entry.get_child().connect('activate',
|
||||
lambda x: self.scan_button.clicked())
|
||||
|
||||
def _create_target(self):
|
||||
@@ -152,7 +152,7 @@ class ScanToolbar(HIGHBox):
|
||||
|
||||
def get_selected_target(self):
|
||||
"""Return currently selected target"""
|
||||
return self.target_entry.selected_target.decode("UTF-8")
|
||||
return self.target_entry.selected_target
|
||||
|
||||
def set_selected_target(self, target):
|
||||
"""Modify currently selected target"""
|
||||
@@ -177,16 +177,16 @@ class ScanToolbar(HIGHBox):
|
||||
selected_target = property(get_selected_target, set_selected_target)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
box = gtk.VBox()
|
||||
w = Gtk.Window()
|
||||
box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
w.add(box)
|
||||
|
||||
stool = ScanToolbar()
|
||||
sctool = ScanCommandToolbar()
|
||||
|
||||
box.pack_start(stool)
|
||||
box.pack_start(sctool)
|
||||
box.pack_start(stool, True, True, 0)
|
||||
box.pack_start(sctool, True, True, 0)
|
||||
|
||||
w.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class ScansListStoreEntry(object):
|
||||
@@ -66,7 +68,7 @@ class ScansListStoreEntry(object):
|
||||
otherwise represented by very different classes."""
|
||||
|
||||
# Possible states for the scan to be in.
|
||||
UNINITIALIZED, RUNNING, FINISHED, FAILED, CANCELED = range(5)
|
||||
UNINITIALIZED, RUNNING, FINISHED, FAILED, CANCELED = list(range(5))
|
||||
|
||||
def __init__(self):
|
||||
self.state = self.UNINITIALIZED
|
||||
@@ -101,11 +103,11 @@ class ScansListStoreEntry(object):
|
||||
canceled = property(lambda self: self.state == self.CANCELED)
|
||||
|
||||
|
||||
class ScansListStore(gtk.ListStore):
|
||||
"""This is a specialization of a gtk.ListStore that holds running,
|
||||
class ScansListStore(Gtk.ListStore):
|
||||
"""This is a specialization of a Gtk.ListStore that holds running,
|
||||
completed, and failed scans."""
|
||||
def __init__(self):
|
||||
gtk.ListStore.__init__(self, object)
|
||||
Gtk.ListStore.__init__(self, object)
|
||||
|
||||
def add_running_scan(self, command):
|
||||
"""Add a running NmapCommand object to the list of scans."""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -59,11 +59,14 @@
|
||||
|
||||
# This module is responsible for interface present under "Scripting" tab.
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
# Prevent loading PyXML
|
||||
import xml
|
||||
@@ -90,7 +93,7 @@ paths_config = PathsConfig()
|
||||
def text_buffer_insert_nsedoc(buf, nsedoc):
|
||||
"""Inserts NSEDoc at the end of the buffer, with markup turned into proper
|
||||
tags."""
|
||||
if not buf.tag_table.lookup("NSEDOC_CODE_TAG"):
|
||||
if not buf.get_tag_table().lookup("NSEDOC_CODE_TAG"):
|
||||
buf.create_tag("NSEDOC_CODE_TAG", font="Monospace")
|
||||
for event in zenmapCore.NSEDocParser.nsedoc_parse(nsedoc):
|
||||
if event.type == "paragraph_start":
|
||||
@@ -102,7 +105,7 @@ def text_buffer_insert_nsedoc(buf, nsedoc):
|
||||
elif event.type == "list_end":
|
||||
pass
|
||||
elif event.type == "list_item_start":
|
||||
buf.insert(buf.get_end_iter(), u"\u2022\u00a0") # bullet nbsp
|
||||
buf.insert(buf.get_end_iter(), "\u2022\u00a0") # bullet nbsp
|
||||
elif event.type == "list_item_end":
|
||||
buf.insert(buf.get_end_iter(), "\n")
|
||||
elif event.type == "text":
|
||||
@@ -123,28 +126,28 @@ class ScriptHelpXMLContentHandler (xml.sax.handler.ContentHandler):
|
||||
self.nselib_dir = None
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
if name == u"directory":
|
||||
if u"name" not in attrs:
|
||||
if name == "directory":
|
||||
if "name" not in attrs:
|
||||
raise ValueError(
|
||||
u'"directory" element did not have "name" attribute')
|
||||
dirname = attrs[u"name"]
|
||||
if u"path" not in attrs:
|
||||
'"directory" element did not have "name" attribute')
|
||||
dirname = attrs["name"]
|
||||
if "path" not in attrs:
|
||||
raise ValueError(
|
||||
u'"directory" element did not have "path" attribute')
|
||||
path = attrs[u"path"].encode("raw_unicode_escape").decode(
|
||||
'"directory" element did not have "path" attribute')
|
||||
path = attrs["path"].encode("raw_unicode_escape").decode(
|
||||
sys.getfilesystemencoding())
|
||||
if dirname == u"scripts":
|
||||
if dirname == "scripts":
|
||||
self.scripts_dir = path
|
||||
elif dirname == u"nselib":
|
||||
elif dirname == "nselib":
|
||||
self.nselib_dir = path
|
||||
else:
|
||||
# Ignore.
|
||||
pass
|
||||
elif name == u"script":
|
||||
if u"filename" not in attrs:
|
||||
elif name == "script":
|
||||
if "filename" not in attrs:
|
||||
raise ValueError(
|
||||
u'"script" element did not have "filename" attribute')
|
||||
self.script_filenames.append(attrs[u"filename"])
|
||||
'"script" element did not have "filename" attribute')
|
||||
self.script_filenames.append(attrs["filename"])
|
||||
|
||||
@staticmethod
|
||||
def parse_nmap_script_help(f):
|
||||
@@ -179,21 +182,21 @@ class ScriptInterface:
|
||||
self.prev_script_spec = None
|
||||
self.focusedentry = None
|
||||
|
||||
self.liststore = gtk.ListStore(str, "gboolean", object)
|
||||
self.liststore = Gtk.ListStore.new([str, bool, object])
|
||||
|
||||
self.file_liststore = gtk.ListStore(str, "gboolean")
|
||||
self.file_liststore = Gtk.ListStore.new([str, bool])
|
||||
|
||||
# Arg name, arg value, (name, desc) tuple.
|
||||
self.arg_liststore = gtk.ListStore(str, str, object)
|
||||
self.arg_liststore = Gtk.ListStore.new([str, str, object])
|
||||
|
||||
# This is what is shown initially. After the initial Nmap run to get
|
||||
# the list of script is finished, this will be replaced with a TreeView
|
||||
# showing the scripts or an error message.
|
||||
self.script_list_container = gtk.VBox()
|
||||
self.script_list_container.pack_start(self.make_please_wait_widget())
|
||||
self.script_list_container = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
self.script_list_container.pack_start(self.make_please_wait_widget(), True, True, 0)
|
||||
self.hmainbox.pack_start(self.script_list_container, False, False, 0)
|
||||
|
||||
self.nmap_error_widget = gtk.Label(_(
|
||||
self.nmap_error_widget = Gtk.Label.new(_(
|
||||
"There was an error getting the list of scripts from Nmap. "
|
||||
"Try upgrading Nmap."))
|
||||
self.nmap_error_widget.set_line_wrap(True)
|
||||
@@ -231,7 +234,7 @@ class ScriptInterface:
|
||||
nmap_process = NmapCommand(command_string)
|
||||
try:
|
||||
nmap_process.run_scan(stderr=stderr)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
callback(False, None)
|
||||
stderr.close()
|
||||
return
|
||||
@@ -239,7 +242,7 @@ class ScriptInterface:
|
||||
|
||||
self.script_list_widget.set_sensitive(False)
|
||||
|
||||
gobject.timeout_add(
|
||||
GLib.timeout_add(
|
||||
self.NMAP_DELAY, self.script_list_timer_callback,
|
||||
nmap_process, callback)
|
||||
|
||||
@@ -269,16 +272,16 @@ class ScriptInterface:
|
||||
for child in self.script_list_container.get_children():
|
||||
self.script_list_container.remove(child)
|
||||
if status and self.handle_initial_script_list_output(process):
|
||||
self.script_list_container.pack_start(self.script_list_widget)
|
||||
self.script_list_container.pack_start(self.script_list_widget, True, True, 0)
|
||||
else:
|
||||
self.script_list_container.pack_start(self.nmap_error_widget)
|
||||
self.script_list_container.pack_start(self.nmap_error_widget, True, True, 0)
|
||||
|
||||
def handle_initial_script_list_output(self, process):
|
||||
process.stdout_file.seek(0)
|
||||
try:
|
||||
handler = ScriptHelpXMLContentHandler.parse_nmap_script_help(
|
||||
process.stdout_file)
|
||||
except (ValueError, xml.sax.SAXParseException), e:
|
||||
except (ValueError, xml.sax.SAXParseException) as e:
|
||||
log.debug("--script-help parse exception: %s" % str(e))
|
||||
return False
|
||||
|
||||
@@ -339,7 +342,7 @@ class ScriptInterface:
|
||||
try:
|
||||
handler = ScriptHelpXMLContentHandler.parse_nmap_script_help(
|
||||
process.stdout_file)
|
||||
except (ValueError, xml.sax.SAXParseException), e:
|
||||
except (ValueError, xml.sax.SAXParseException) as e:
|
||||
log.debug("--script-help parse exception: %s" % str(e))
|
||||
return False
|
||||
|
||||
@@ -375,8 +378,8 @@ class ScriptInterface:
|
||||
involving the creation of a subprocess, we don't do it for every typed
|
||||
character."""
|
||||
if self.script_list_timeout_id:
|
||||
gobject.source_remove(self.script_list_timeout_id)
|
||||
self.script_list_timeout_id = gobject.timeout_add(
|
||||
GLib.source_remove(self.script_list_timeout_id)
|
||||
self.script_list_timeout_id = GLib.timeout_add(
|
||||
self.SCRIPT_LIST_DELAY,
|
||||
self.update_script_list_from_spec, spec)
|
||||
|
||||
@@ -413,34 +416,34 @@ A list of arguments that affect the selected script. Enter a value by \
|
||||
clicking in the value field beside the argument name.""")
|
||||
|
||||
def make_please_wait_widget(self):
|
||||
vbox = gtk.VBox()
|
||||
label = gtk.Label(_("Please wait."))
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
label = Gtk.Label.new(_("Please wait."))
|
||||
label.set_line_wrap(True)
|
||||
vbox.pack_start(label)
|
||||
vbox.pack_start(label, True, True, 0)
|
||||
return vbox
|
||||
|
||||
def make_script_list_widget(self):
|
||||
"""Creates and packs widgets associated with left hand side of
|
||||
Interface."""
|
||||
vbox = gtk.VBox()
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
scrolled_window = HIGScrolledWindow()
|
||||
scrolled_window.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
|
||||
scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
|
||||
# Expand only vertically.
|
||||
scrolled_window.set_size_request(175, -1)
|
||||
listview = gtk.TreeView(self.liststore)
|
||||
listview = Gtk.TreeView.new_with_model(self.liststore)
|
||||
listview.set_headers_visible(False)
|
||||
listview.connect("enter-notify-event", self.update_help_ls_cb)
|
||||
selection = listview.get_selection()
|
||||
selection.connect("changed", self.selection_changed_cb)
|
||||
cell = gtk.CellRendererText()
|
||||
togglecell = gtk.CellRendererToggle()
|
||||
cell = Gtk.CellRendererText()
|
||||
togglecell = Gtk.CellRendererToggle()
|
||||
togglecell.set_property("activatable", True)
|
||||
togglecell.connect("toggled", self.toggled_cb, self.liststore)
|
||||
col = gtk.TreeViewColumn(_('Names'))
|
||||
col.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
|
||||
col = Gtk.TreeViewColumn(title=_('Names'))
|
||||
col.set_sizing(Gtk.TreeViewColumnSizing.GROW_ONLY)
|
||||
col.set_resizable(True)
|
||||
togglecol = gtk.TreeViewColumn(None, togglecell)
|
||||
togglecol = Gtk.TreeViewColumn(title=None, cell_renderer=togglecell)
|
||||
togglecol.add_attribute(togglecell, "active", 1)
|
||||
listview.append_column(togglecol)
|
||||
listview.append_column(col)
|
||||
@@ -452,40 +455,40 @@ clicking in the value field beside the argument name.""")
|
||||
|
||||
self.file_scrolled_window = HIGScrolledWindow()
|
||||
self.file_scrolled_window.set_policy(
|
||||
gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
|
||||
Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
|
||||
self.file_scrolled_window.set_size_request(175, -1)
|
||||
self.file_scrolled_window.hide()
|
||||
self.file_scrolled_window.set_no_show_all(True)
|
||||
|
||||
self.file_listview = gtk.TreeView(self.file_liststore)
|
||||
self.file_listview = Gtk.TreeView.new_with_model(self.file_liststore)
|
||||
self.file_listview.set_headers_visible(False)
|
||||
col = gtk.TreeViewColumn(None)
|
||||
col = Gtk.TreeViewColumn(title=None)
|
||||
self.file_listview.append_column(col)
|
||||
cell = gtk.CellRendererToggle()
|
||||
cell = Gtk.CellRendererToggle()
|
||||
col.pack_start(cell, True)
|
||||
cell.set_property("activatable", True)
|
||||
col.add_attribute(cell, "active", 1)
|
||||
cell.connect("toggled", self.toggled_cb, self.file_liststore)
|
||||
|
||||
col = gtk.TreeViewColumn(None)
|
||||
col = Gtk.TreeViewColumn(title=None)
|
||||
self.file_listview.append_column(col)
|
||||
cell = gtk.CellRendererText()
|
||||
col.pack_start(cell)
|
||||
cell = Gtk.CellRendererText()
|
||||
col.pack_start(cell, True)
|
||||
col.add_attribute(cell, "text", 0)
|
||||
|
||||
self.file_listview.show_all()
|
||||
self.file_scrolled_window.add(self.file_listview)
|
||||
vbox.pack_start(self.file_scrolled_window, False)
|
||||
vbox.pack_start(self.file_scrolled_window, False, True, 0)
|
||||
|
||||
hbox = HIGHBox(False, 2)
|
||||
self.remove_file_button = HIGButton(stock=gtk.STOCK_REMOVE)
|
||||
self.remove_file_button = HIGButton(stock=Gtk.STOCK_REMOVE)
|
||||
self.remove_file_button.connect(
|
||||
"clicked", self.remove_file_button_clicked_cb)
|
||||
self.remove_file_button.set_sensitive(False)
|
||||
hbox.pack_end(self.remove_file_button)
|
||||
add_file_button = HIGButton(stock=gtk.STOCK_ADD)
|
||||
hbox.pack_end(self.remove_file_button, True, True, 0)
|
||||
add_file_button = HIGButton(stock=Gtk.STOCK_ADD)
|
||||
add_file_button.connect("clicked", self.add_file_button_clicked_cb)
|
||||
hbox.pack_end(add_file_button)
|
||||
hbox.pack_end(add_file_button, True, True, 0)
|
||||
|
||||
vbox.pack_start(hbox, False, False, 0)
|
||||
|
||||
@@ -541,35 +544,35 @@ clicking in the value field beside the argument name.""")
|
||||
"""Creates and packs widgets related to displaying the description
|
||||
box."""
|
||||
sw = HIGScrolledWindow()
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
|
||||
sw.set_shadow_type(gtk.SHADOW_OUT)
|
||||
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
|
||||
sw.set_shadow_type(Gtk.ShadowType.OUT)
|
||||
sw.set_border_width(5)
|
||||
text_view = gtk.TextView()
|
||||
text_view = Gtk.TextView()
|
||||
text_view.connect("enter-notify-event", self.update_help_desc_cb)
|
||||
self.text_buffer = text_view.get_buffer()
|
||||
self.text_buffer.create_tag("Usage", font="Monospace")
|
||||
self.text_buffer.create_tag("Output", font="Monospace")
|
||||
text_view.set_wrap_mode(gtk.WRAP_WORD)
|
||||
text_view.set_wrap_mode(Gtk.WrapMode.WORD)
|
||||
text_view.set_editable(False)
|
||||
text_view.set_justification(gtk.JUSTIFY_LEFT)
|
||||
text_view.set_justification(Gtk.Justification.LEFT)
|
||||
sw.add(text_view)
|
||||
return sw
|
||||
|
||||
def make_arguments_widget(self):
|
||||
"""Creates and packs widgets related to arguments box."""
|
||||
vbox = gtk.VBox()
|
||||
vbox.pack_start(gtk.Label(_("Arguments")), False, False, 0)
|
||||
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
vbox.pack_start(Gtk.Label.new(_("Arguments")), False, False, 0)
|
||||
arg_window = HIGScrolledWindow()
|
||||
arg_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
|
||||
arg_window.set_shadow_type(gtk.SHADOW_OUT)
|
||||
arg_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
|
||||
arg_window.set_shadow_type(Gtk.ShadowType.OUT)
|
||||
|
||||
arg_listview = gtk.TreeView(self.arg_liststore)
|
||||
arg_listview = Gtk.TreeView.new_with_model(self.arg_liststore)
|
||||
arg_listview.connect("motion-notify-event", self.update_help_arg_cb)
|
||||
argument = gtk.CellRendererText()
|
||||
self.value = gtk.CellRendererText()
|
||||
argument = Gtk.CellRendererText()
|
||||
self.value = Gtk.CellRendererText()
|
||||
self.value.connect("edited", self.value_edited_cb, self.arg_liststore)
|
||||
arg_col = gtk.TreeViewColumn("Arguments\t")
|
||||
val_col = gtk.TreeViewColumn("values")
|
||||
arg_col = Gtk.TreeViewColumn(title="Arguments\t")
|
||||
val_col = Gtk.TreeViewColumn(title="values")
|
||||
arg_listview.append_column(arg_col)
|
||||
arg_listview.append_column(val_col)
|
||||
arg_col.pack_start(argument, True)
|
||||
@@ -626,11 +629,7 @@ clicking in the value field beside the argument name.""")
|
||||
def update_help_arg_cb(self, treeview, event):
|
||||
"""Callback method for displaying argument help."""
|
||||
wx, wy = treeview.get_pointer()
|
||||
try:
|
||||
x, y = treeview.convert_widget_to_bin_window_coords(wx, wy)
|
||||
except AttributeError:
|
||||
# convert_widget_to_bin_window_coords was introduced in PyGTK 2.12.
|
||||
return
|
||||
path = treeview.get_path_at_pos(x, y)
|
||||
if not path or not self.focusedentry:
|
||||
self.help_buf.set_text("")
|
||||
@@ -654,7 +653,7 @@ clicking in the value field beside the argument name.""")
|
||||
response = self.script_file_chooser.run()
|
||||
filenames = self.script_file_chooser.get_filenames()
|
||||
self.script_file_chooser.hide()
|
||||
if response != gtk.RESPONSE_OK:
|
||||
if response != Gtk.ResponseType.OK:
|
||||
return
|
||||
for filename in filenames:
|
||||
self.file_liststore.append([filename, True])
|
||||
@@ -675,7 +674,7 @@ clicking in the value field beside the argument name.""")
|
||||
|
||||
def set_description(self, entry):
|
||||
"""Sets the content that is to be displayed in the description box."""
|
||||
self.text_buffer.set_text(u"")
|
||||
self.text_buffer.set_text("")
|
||||
|
||||
self.text_buffer.insert(self.text_buffer.get_end_iter(), """\
|
||||
Categories: %(cats)s
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,11 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
import re
|
||||
import copy
|
||||
|
||||
@@ -140,12 +143,12 @@ class SearchParser(object):
|
||||
self.search_gui.init_search_dirs(self.search_dict.pop("dir", []))
|
||||
|
||||
|
||||
class SearchGUI(gtk.VBox, object):
|
||||
class SearchGUI(Gtk.Box, object):
|
||||
"""This class is a VBox that holds the search entry field and buttons on
|
||||
top, and the results list on the bottom. The "Cancel" and "Open" buttons
|
||||
are a part of the SearchWindow class, not SearchGUI."""
|
||||
def __init__(self, search_window):
|
||||
gtk.VBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
self._create_widgets()
|
||||
self._pack_widgets()
|
||||
@@ -168,7 +171,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
if self.options["search_db"]:
|
||||
try:
|
||||
self.search_db = SearchDB()
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
self.search_db = SearchDummy()
|
||||
self.no_db_warning.show()
|
||||
self.no_db_warning.set_text(
|
||||
@@ -250,25 +253,26 @@ class SearchGUI(gtk.VBox, object):
|
||||
# Search box and buttons
|
||||
self.search_top_hbox = HIGHBox()
|
||||
self.search_label = HIGSectionLabel(_("Search:"))
|
||||
self.search_entry = gtk.Entry()
|
||||
self.search_entry = Gtk.Entry()
|
||||
self.expressions_btn = HIGToggleButton(
|
||||
_("Expressions "), gtk.STOCK_EDIT)
|
||||
_("Expressions "), Gtk.STOCK_EDIT)
|
||||
|
||||
# The quick reference tooltip button
|
||||
self.search_tooltip_btn = HIGButton(" ", gtk.STOCK_INFO)
|
||||
self.search_tooltip_btn = HIGButton(" ", Gtk.STOCK_INFO)
|
||||
|
||||
# The expression VBox. This is only visible once the user clicks on
|
||||
# "Expressions"
|
||||
self.expr_vbox = gtk.VBox()
|
||||
# "Expressions". The expressions (if any) should be tightly packed so
|
||||
# that they don't take too much screen real-estate
|
||||
self.expr_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
# Results section
|
||||
self.result_list = gtk.ListStore(str, str, int) # title, date, id
|
||||
self.result_view = gtk.TreeView(self.result_list)
|
||||
self.result_scrolled = gtk.ScrolledWindow()
|
||||
self.result_title_column = gtk.TreeViewColumn(_("Scan"))
|
||||
self.result_date_column = gtk.TreeViewColumn(_("Date"))
|
||||
self.result_list = Gtk.ListStore.new([str, str, int]) # title, date, id
|
||||
self.result_view = Gtk.TreeView.new_with_model(self.result_list)
|
||||
self.result_scrolled = Gtk.ScrolledWindow()
|
||||
self.result_title_column = Gtk.TreeViewColumn(title=_("Scan"))
|
||||
self.result_date_column = Gtk.TreeViewColumn(title=_("Date"))
|
||||
|
||||
self.no_db_warning = gtk.Label()
|
||||
self.no_db_warning = Gtk.Label()
|
||||
self.no_db_warning.set_line_wrap(True)
|
||||
self.no_db_warning.set_no_show_all(True)
|
||||
|
||||
@@ -277,26 +281,22 @@ class SearchGUI(gtk.VBox, object):
|
||||
def _pack_widgets(self):
|
||||
# Packing label, search box and buttons
|
||||
self.search_top_hbox.set_spacing(4)
|
||||
self.search_top_hbox.pack_start(self.search_label, False)
|
||||
self.search_top_hbox.pack_start(self.search_entry, True)
|
||||
self.search_top_hbox.pack_start(self.expressions_btn, False)
|
||||
self.search_top_hbox.pack_start(self.search_tooltip_btn, False)
|
||||
|
||||
# The expressions (if any) should be tightly packed so that they don't
|
||||
# take too much screen real-estate
|
||||
self.expr_vbox.set_spacing(0)
|
||||
self.search_top_hbox.pack_start(self.search_label, False, True, 0)
|
||||
self.search_top_hbox.pack_start(self.search_entry, True, True, 0)
|
||||
self.search_top_hbox.pack_start(self.expressions_btn, False, True, 0)
|
||||
self.search_top_hbox.pack_start(self.search_tooltip_btn, False, True, 0)
|
||||
|
||||
# Packing the result section
|
||||
self.result_scrolled.add(self.result_view)
|
||||
self.result_scrolled.set_policy(
|
||||
gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
|
||||
# Packing it all together
|
||||
self.set_spacing(4)
|
||||
self.pack_start(self.search_top_hbox, False)
|
||||
self.pack_start(self.expr_vbox, False)
|
||||
self.pack_start(self.result_scrolled, True)
|
||||
self.pack_start(self.no_db_warning, False)
|
||||
self.pack_start(self.search_top_hbox, False, True, 0)
|
||||
self.pack_start(self.expr_vbox, False, True, 0)
|
||||
self.pack_start(self.result_scrolled, True, True, 0)
|
||||
self.pack_start(self.no_db_warning, False, True, 0)
|
||||
|
||||
def _connect_events(self):
|
||||
self.search_entry.connect("changed", self.update_search_entry)
|
||||
@@ -313,7 +313,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
# This is the first time the user has clicked on "Show Expressions"
|
||||
# and the search entry box is empty, so we add a single Criterion
|
||||
# row
|
||||
self.expr_vbox.pack_start(Criterion(self))
|
||||
self.expr_vbox.pack_start(Criterion(self), True, True, 0)
|
||||
|
||||
if self.expressions_btn.get_active():
|
||||
# The Expressions GUI is about to be displayed. It needs to reflect
|
||||
@@ -336,12 +336,12 @@ class SearchGUI(gtk.VBox, object):
|
||||
# We compare the search entry field to the Expressions GUI. Every
|
||||
# (operator, value) pair must be present in the GUI after this loop
|
||||
# is done.
|
||||
for op, args in self.search_dict.iteritems():
|
||||
for op, args in self.search_dict.items():
|
||||
for arg in args:
|
||||
if (op not in gui_ops) or (arg not in gui_ops[op]):
|
||||
# We need to add this pair to the GUI
|
||||
self.expr_vbox.pack_start(
|
||||
Criterion(self, op, arg), False)
|
||||
Criterion(self, op, arg), False, True, 0)
|
||||
|
||||
# Now we check if there are any leftover criterion rows that aren't
|
||||
# present in the search_dict (for example, if a user has deleted
|
||||
@@ -353,7 +353,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
criterion.destroy()
|
||||
# If we have deleted all rows, add an empty one
|
||||
if len(self.expr_vbox.get_children()) == 0:
|
||||
self.expr_vbox.pack_start(Criterion(self))
|
||||
self.expr_vbox.pack_start(Criterion(self), True, True, 0)
|
||||
|
||||
# Display all elements
|
||||
self.expr_vbox.show_all()
|
||||
@@ -361,7 +361,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
# The Expressions GUI is about to be hidden. No updates to the
|
||||
# search entry field are necessary, since it gets updated on every
|
||||
# change in one of the criterion rows.
|
||||
self.expr_vbox.hide_all()
|
||||
self.expr_vbox.hide()
|
||||
self.search_entry.set_sensitive(True)
|
||||
|
||||
def close(self):
|
||||
@@ -375,7 +375,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
|
||||
# Make a new Criteria row and insert it after the calling row
|
||||
criteria = Criterion(self, "keyword")
|
||||
self.expr_vbox.pack_start(criteria, False)
|
||||
self.expr_vbox.pack_start(criteria, False, True, 0)
|
||||
self.expr_vbox.reorder_child(criteria, caller_index + 1)
|
||||
criteria.show_all()
|
||||
|
||||
@@ -431,7 +431,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
self.append_result(result)
|
||||
matched += 1
|
||||
|
||||
for search_dir in self.search_dirs.itervalues():
|
||||
for search_dir in self.search_dirs.values():
|
||||
total += len(search_dir.get_scan_results())
|
||||
for result in search_dir.search(**self.search_dict):
|
||||
self.append_result(result)
|
||||
@@ -448,7 +448,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
|
||||
def clear_result_list(self):
|
||||
for i in range(len(self.result_list)):
|
||||
iter = self.result_list.get_iter_root()
|
||||
iter = self.result_list.get_iter_first()
|
||||
del(self.result_list[iter])
|
||||
|
||||
def append_result(self, parsed_result):
|
||||
@@ -481,7 +481,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
self.result_view.set_search_column(0)
|
||||
|
||||
selection = self.result_view.get_selection()
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
self.result_view.append_column(self.result_title_column)
|
||||
self.result_view.append_column(self.result_date_column)
|
||||
@@ -496,7 +496,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
self.result_title_column.set_reorderable(True)
|
||||
self.result_date_column.set_reorderable(True)
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cell = Gtk.CellRendererText()
|
||||
|
||||
self.result_title_column.pack_start(cell, True)
|
||||
self.result_date_column.pack_start(cell, True)
|
||||
@@ -507,7 +507,7 @@ class SearchGUI(gtk.VBox, object):
|
||||
selected_results = property(get_selected_results)
|
||||
|
||||
|
||||
class Criterion(gtk.HBox):
|
||||
class Criterion(Gtk.Box):
|
||||
"""This class holds one criterion row, represented as an HBox. It holds a
|
||||
ComboBox and a Subcriterion's subclass instance, depending on the selected
|
||||
entry in the ComboBox. For example, when the 'Target' option is selected, a
|
||||
@@ -517,7 +517,7 @@ class Criterion(gtk.HBox):
|
||||
def __init__(self, search_window, operator="keyword", argument=""):
|
||||
"""A reference to the search window is passed so that we can call
|
||||
add_criterion and remove_criterion."""
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.search_window = search_window
|
||||
self.default_operator = operator
|
||||
@@ -544,17 +544,17 @@ class Criterion(gtk.HBox):
|
||||
|
||||
def _create_widgets(self):
|
||||
# A ComboBox containing the list of operators
|
||||
self.operator_combo = gtk.combo_box_new_text()
|
||||
self.operator_combo = Gtk.ComboBoxText()
|
||||
|
||||
# Sort all the keys from combo_entries and make an entry for each of
|
||||
# them
|
||||
sorted_entries = self.combo_entries.keys()
|
||||
sorted_entries = list(self.combo_entries.keys())
|
||||
sorted_entries.sort()
|
||||
for name in sorted_entries:
|
||||
self.operator_combo.append_text(name)
|
||||
|
||||
# Select the default operator
|
||||
for entry, operators in self.combo_entries.iteritems():
|
||||
for entry, operators in self.combo_entries.items():
|
||||
for operator in operators:
|
||||
if operator == self.default_operator:
|
||||
self.operator_combo.set_active(sorted_entries.index(entry))
|
||||
@@ -565,14 +565,14 @@ class Criterion(gtk.HBox):
|
||||
self.default_operator, self.default_argument)
|
||||
|
||||
# The "add" and "remove" buttons
|
||||
self.add_btn = HIGButton(" ", gtk.STOCK_ADD)
|
||||
self.remove_btn = HIGButton(" ", gtk.STOCK_REMOVE)
|
||||
self.add_btn = HIGButton(" ", Gtk.STOCK_ADD)
|
||||
self.remove_btn = HIGButton(" ", Gtk.STOCK_REMOVE)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.operator_combo, False)
|
||||
self.pack_start(self.subcriterion, True, True)
|
||||
self.pack_start(self.add_btn, False)
|
||||
self.pack_start(self.remove_btn, False)
|
||||
self.pack_start(self.operator_combo, False, True, 0)
|
||||
self.pack_start(self.subcriterion, True, True, 0)
|
||||
self.pack_start(self.add_btn, False, True, 0)
|
||||
self.pack_start(self.remove_btn, False, True, 0)
|
||||
|
||||
def _connect_events(self):
|
||||
self.operator_combo.connect("changed", self.operator_changed)
|
||||
@@ -619,7 +619,7 @@ class Criterion(gtk.HBox):
|
||||
self.subcriterion = self.new_subcriterion(operator)
|
||||
|
||||
# Pack it, and place it on the right side of the ComboBox
|
||||
self.pack_start(self.subcriterion, True, True)
|
||||
self.pack_start(self.subcriterion, True, True, 0)
|
||||
self.reorder_child(self.subcriterion, 1)
|
||||
|
||||
# Notify the search window about the change
|
||||
@@ -632,12 +632,12 @@ class Criterion(gtk.HBox):
|
||||
argument = property(get_argument)
|
||||
|
||||
|
||||
class Subcriterion(gtk.HBox):
|
||||
class Subcriterion(Gtk.Box):
|
||||
"""This class is a base class for all subcriterion types. Depending on the
|
||||
criterion selected in the Criterion's ComboBox, a subclass of Subcriterion
|
||||
is created to display the appropriate GUI."""
|
||||
def __init__(self):
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.operator = ""
|
||||
self.argument = ""
|
||||
@@ -662,12 +662,12 @@ class SimpleSubcriterion(Subcriterion):
|
||||
self._connect_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.entry = gtk.Entry()
|
||||
self.entry = Gtk.Entry()
|
||||
if self.argument:
|
||||
self.entry.set_text(self.argument)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.entry, True)
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.entry.connect("changed", self.entry_changed)
|
||||
@@ -690,13 +690,13 @@ class PortSubcriterion(Subcriterion):
|
||||
self._connect_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.entry = gtk.Entry()
|
||||
self.entry = Gtk.Entry()
|
||||
if self.argument:
|
||||
self.entry.set_text(self.argument)
|
||||
|
||||
self.label = gtk.Label(" is ")
|
||||
self.label = Gtk.Label.new(" is ")
|
||||
|
||||
self.port_state_combo = gtk.combo_box_new_text()
|
||||
self.port_state_combo = Gtk.ComboBoxText()
|
||||
states = ["open", "scanned", "closed", "filtered", "unfiltered",
|
||||
"open|filtered", "closed|filtered"]
|
||||
for state in states:
|
||||
@@ -705,9 +705,9 @@ class PortSubcriterion(Subcriterion):
|
||||
states.index(self.operator.replace("_", "|")))
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.entry, True)
|
||||
self.pack_start(self.label, False)
|
||||
self.pack_start(self.port_state_combo, False)
|
||||
self.pack_start(self.entry, True, True, 0)
|
||||
self.pack_start(self.label, False, True, 0)
|
||||
self.pack_start(self.port_state_combo, False, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.entry.connect("changed", self.entry_changed)
|
||||
@@ -734,14 +734,14 @@ class DirSubcriterion(Subcriterion):
|
||||
self._connect_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.dir_entry = gtk.Entry()
|
||||
self.dir_entry = Gtk.Entry()
|
||||
if self.argument:
|
||||
self.dir_entry.set_text(self.argument)
|
||||
self.chooser_btn = HIGButton("Choose...", gtk.STOCK_OPEN)
|
||||
self.chooser_btn = HIGButton("Choose...", Gtk.STOCK_OPEN)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.dir_entry, True)
|
||||
self.pack_start(self.chooser_btn, False)
|
||||
self.pack_start(self.dir_entry, True, True, 0)
|
||||
self.pack_start(self.chooser_btn, False, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.chooser_btn.connect("clicked", self.choose_clicked)
|
||||
@@ -751,7 +751,7 @@ class DirSubcriterion(Subcriterion):
|
||||
# Display a directory chooser dialog
|
||||
chooser_dlg = DirectoryChooserDialog("Include folder in search")
|
||||
|
||||
if chooser_dlg.run() == gtk.RESPONSE_OK:
|
||||
if chooser_dlg.run() == Gtk.ResponseType.OK:
|
||||
self.dir_entry.set_text(chooser_dlg.get_filename())
|
||||
|
||||
chooser_dlg.destroy()
|
||||
@@ -801,7 +801,7 @@ class DateSubcriterion(Subcriterion):
|
||||
self.argument += "~" * self.fuzzies
|
||||
|
||||
def _create_widgets(self):
|
||||
self.date_criterion_combo = gtk.combo_box_new_text()
|
||||
self.date_criterion_combo = Gtk.ComboBoxText()
|
||||
self.date_criterion_combo.append_text("is")
|
||||
self.date_criterion_combo.append_text("after")
|
||||
self.date_criterion_combo.append_text("before")
|
||||
@@ -814,8 +814,8 @@ class DateSubcriterion(Subcriterion):
|
||||
self.date_button = HIGButton()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.pack_start(self.date_criterion_combo, False)
|
||||
self.pack_start(self.date_button, True)
|
||||
self.pack_start(self.date_criterion_combo, False, True, 0)
|
||||
self.pack_start(self.date_button, True, True, 0)
|
||||
|
||||
def _connect_widgets(self):
|
||||
self.date_criterion_combo.connect(
|
||||
@@ -835,7 +835,7 @@ class DateSubcriterion(Subcriterion):
|
||||
|
||||
def update_button(self, widget):
|
||||
cal_date = widget.get_date()
|
||||
# Add 1 to month because gtk.Calendar date is zero-based.
|
||||
# Add 1 to month because Gtk.Calendar date is zero-based.
|
||||
self.date = datetime.date(cal_date[0], cal_date[1] + 1, cal_date[2])
|
||||
|
||||
# Set the argument, using the search format
|
||||
@@ -866,12 +866,12 @@ class DateSubcriterion(Subcriterion):
|
||||
_date = datetime.date.today()
|
||||
|
||||
|
||||
class DateCalendar(gtk.Window, object):
|
||||
class DateCalendar(Gtk.Window, object):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||
self.set_position(gtk.WIN_POS_MOUSE)
|
||||
Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
|
||||
self.set_position(Gtk.WindowPosition.MOUSE)
|
||||
|
||||
self.calendar = gtk.Calendar()
|
||||
self.calendar = Gtk.Calendar()
|
||||
self.add(self.calendar)
|
||||
|
||||
def connect_calendar(self, update_button_cb):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.SearchGUI import SearchGUI
|
||||
|
||||
@@ -81,17 +83,17 @@ if is_maemo():
|
||||
def _pack_widgets(self):
|
||||
pass
|
||||
else:
|
||||
class BaseSearchWindow(gtk.Window):
|
||||
class BaseSearchWindow(Gtk.Window):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
Gtk.Window.__init__(self)
|
||||
self.set_title(_("Search Scans"))
|
||||
self.set_position(gtk.WIN_POS_CENTER)
|
||||
self.set_position(Gtk.WindowPosition.CENTER)
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.vbox.set_border_width(4)
|
||||
|
||||
|
||||
class SearchWindow(BaseSearchWindow, object):
|
||||
class SearchWindow(BaseSearchWindow):
|
||||
def __init__(self, load_method, append_method):
|
||||
BaseSearchWindow.__init__(self)
|
||||
|
||||
@@ -107,34 +109,33 @@ class SearchWindow(BaseSearchWindow, object):
|
||||
def _create_widgets(self):
|
||||
self.vbox = HIGVBox()
|
||||
|
||||
self.bottom_hbox = gtk.HBox()
|
||||
self.bottom_label = gtk.Label()
|
||||
self.btn_box = gtk.HButtonBox()
|
||||
self.btn_open = HIGButton(stock=gtk.STOCK_OPEN)
|
||||
self.btn_append = HIGButton(_("Append"), gtk.STOCK_ADD)
|
||||
self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
|
||||
self.bottom_hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 4)
|
||||
self.bottom_label = Gtk.Label()
|
||||
self.btn_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
|
||||
self.btn_open = HIGButton(stock=Gtk.STOCK_OPEN)
|
||||
self.btn_append = HIGButton(_("Append"), Gtk.STOCK_ADD)
|
||||
self.btn_close = HIGButton(stock=Gtk.STOCK_CLOSE)
|
||||
|
||||
self.search_gui = SearchGUI(self)
|
||||
|
||||
def _pack_widgets(self):
|
||||
BaseSearchWindow._pack_widgets(self)
|
||||
|
||||
self.btn_box.set_layout(gtk.BUTTONBOX_END)
|
||||
self.btn_box.set_layout(Gtk.ButtonBoxStyle.END)
|
||||
self.btn_box.set_spacing(4)
|
||||
self.btn_box.pack_start(self.btn_close)
|
||||
self.btn_box.pack_start(self.btn_append)
|
||||
self.btn_box.pack_start(self.btn_open)
|
||||
self.btn_box.pack_start(self.btn_close, True, True, 0)
|
||||
self.btn_box.pack_start(self.btn_append, True, True, 0)
|
||||
self.btn_box.pack_start(self.btn_open, True, True, 0)
|
||||
|
||||
self.bottom_label.set_alignment(0.0, 0.5)
|
||||
self.bottom_label.set_use_markup(True)
|
||||
|
||||
self.bottom_hbox.set_spacing(4)
|
||||
self.bottom_hbox.pack_start(self.bottom_label, True)
|
||||
self.bottom_hbox.pack_start(self.btn_box, False)
|
||||
self.bottom_hbox.pack_start(self.bottom_label, True, True, 0)
|
||||
self.bottom_hbox.pack_start(self.btn_box, False, True, 0)
|
||||
|
||||
self.vbox.set_spacing(4)
|
||||
self.vbox.pack_start(self.search_gui, True, True)
|
||||
self.vbox.pack_start(self.bottom_hbox, False)
|
||||
self.vbox.pack_start(self.search_gui, True, True, 0)
|
||||
self.vbox.pack_start(self.bottom_hbox, False, True, 0)
|
||||
|
||||
self.add(self.vbox)
|
||||
|
||||
@@ -179,6 +180,6 @@ class SearchWindow(BaseSearchWindow, object):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
search = SearchWindow(lambda x: gtk.main_quit(), lambda x: gtk.main_quit())
|
||||
search = SearchWindow(lambda x: Gtk.main_quit(), lambda x: Gtk.main_quit())
|
||||
search.show_all()
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,48 +57,49 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapCore.TargetList import target_list
|
||||
|
||||
|
||||
class TargetCombo(gtk.ComboBoxEntry):
|
||||
class TargetCombo(Gtk.ComboBoxText):
|
||||
def __init__(self):
|
||||
gtk.ComboBoxEntry.__init__(self, gtk.ListStore(str), 0)
|
||||
Gtk.ComboBoxText.__init__(self, has_entry=True)
|
||||
|
||||
self.completion = gtk.EntryCompletion()
|
||||
self.child.set_completion(self.completion)
|
||||
self.completion = Gtk.EntryCompletion()
|
||||
self.get_child().set_completion(self.completion)
|
||||
self.completion.set_model(self.get_model())
|
||||
self.completion.set_text_column(0)
|
||||
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
t_model = self.get_model()
|
||||
for i in range(len(t_model)):
|
||||
iter = t_model.get_iter_root()
|
||||
del(t_model[iter])
|
||||
self.remove_all()
|
||||
|
||||
t_list = target_list.get_target_list()
|
||||
for target in t_list[:15]:
|
||||
t_model.append([target.replace('\n', '')])
|
||||
self.append_text(target.replace('\n', ''))
|
||||
|
||||
def add_new_target(self, target):
|
||||
target_list.add_target(target)
|
||||
self.update()
|
||||
|
||||
def get_selected_target(self):
|
||||
return self.child.get_text()
|
||||
return self.get_child().get_text()
|
||||
|
||||
def set_selected_target(self, target):
|
||||
self.child.set_text(target)
|
||||
self.get_child().set_text(target)
|
||||
|
||||
selected_target = property(get_selected_target, set_selected_target)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
t = TargetCombo()
|
||||
w.add(t)
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,7 +57,10 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from zenmapGUI.higwidgets.higboxes import HIGVBox
|
||||
|
||||
@@ -84,9 +86,8 @@ class TopologyPage(HIGVBox):
|
||||
self._pack_widgets()
|
||||
|
||||
def _create_widgets(self):
|
||||
self.rn_hbox = gtk.HBox()
|
||||
self.rn_hbox.set_spacing(4)
|
||||
self.rn_vbox = gtk.VBox()
|
||||
self.rn_hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 4)
|
||||
self.rn_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
|
||||
# RadialNet's widgets
|
||||
self.radialnet = RadialNet.RadialNet(RadialNet.LAYOUT_WEIGHTED)
|
||||
@@ -102,11 +103,11 @@ class TopologyPage(HIGVBox):
|
||||
self.radialnet.set_no_show_all(True)
|
||||
|
||||
self.slow_vbox = HIGVBox()
|
||||
self.slow_label = gtk.Label()
|
||||
self.slow_vbox.pack_start(self.slow_label, False, False)
|
||||
show_button = gtk.Button(_("Show the topology anyway"))
|
||||
self.slow_label = Gtk.Label()
|
||||
self.slow_vbox.pack_start(self.slow_label, False, False, 0)
|
||||
show_button = Gtk.Button.new_with_label(_("Show the topology anyway"))
|
||||
show_button.connect("clicked", self.show_anyway)
|
||||
self.slow_vbox.pack_start(show_button, False, False)
|
||||
self.slow_vbox.pack_start(show_button, False, False, 0)
|
||||
self.slow_vbox.show_all()
|
||||
self.slow_vbox.set_no_show_all(True)
|
||||
self.slow_vbox.hide()
|
||||
@@ -114,17 +115,17 @@ class TopologyPage(HIGVBox):
|
||||
self.radialnet.show()
|
||||
|
||||
def _pack_widgets(self):
|
||||
self.rn_hbox.pack_start(self.display_panel, True, True)
|
||||
self.rn_hbox.pack_start(self.control, False)
|
||||
self.rn_hbox.pack_start(self.display_panel, True, True, 0)
|
||||
self.rn_hbox.pack_start(self.control, False, True, 0)
|
||||
|
||||
self.rn_vbox.pack_start(self.rn_hbox, True, True)
|
||||
self.rn_vbox.pack_start(self.fisheye, False)
|
||||
self.rn_vbox.pack_start(self.rn_hbox, True, True, 0)
|
||||
self.rn_vbox.pack_start(self.fisheye, False, True, 0)
|
||||
|
||||
self.pack_start(self.rn_toolbar, False, False)
|
||||
self.pack_start(self.rn_vbox, True, True)
|
||||
self.pack_start(self.rn_toolbar, False, False, 0)
|
||||
self.pack_start(self.rn_vbox, True, True, 0)
|
||||
|
||||
self.display_panel.pack_start(self.slow_vbox, True, False)
|
||||
self.display_panel.pack_start(self.radialnet, True, True)
|
||||
self.display_panel.pack_start(self.slow_vbox, True, False, 0)
|
||||
self.display_panel.pack_start(self.radialnet, True, True, 0)
|
||||
|
||||
def add_scan(self, scan):
|
||||
"""Parses a given XML file and adds the parsed result to the network
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -68,17 +67,17 @@ This is mostly implemented by subclassing from the GTK classes, and
|
||||
providing defaults that better match the HIG specifications/recommendations.
|
||||
"""
|
||||
|
||||
from gtkutils import *
|
||||
from higboxes import *
|
||||
from higbuttons import *
|
||||
from higdialogs import *
|
||||
from higentries import *
|
||||
from higexpanders import *
|
||||
from higlabels import *
|
||||
from higlogindialogs import *
|
||||
from higprogressbars import *
|
||||
from higscrollers import *
|
||||
from higspinner import *
|
||||
from higtables import *
|
||||
from higtextviewers import *
|
||||
from higwindows import *
|
||||
from .gtkutils import *
|
||||
from .higboxes import *
|
||||
from .higbuttons import *
|
||||
from .higdialogs import *
|
||||
from .higentries import *
|
||||
from .higexpanders import *
|
||||
from .higlabels import *
|
||||
from .higlogindialogs import *
|
||||
from .higprogressbars import *
|
||||
from .higscrollers import *
|
||||
from .higspinner import *
|
||||
from .higtables import *
|
||||
from .higtextviewers import *
|
||||
from .higwindows import *
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -65,43 +64,34 @@ higwidgets/gtkutils.py
|
||||
"""
|
||||
|
||||
__all__ = ['gtk_version_major', 'gtk_version_minor', 'gtk_version_release',
|
||||
'gtk_constant_name', 'gobject_register']
|
||||
'gtk_constant_name']
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
# version information
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gtk.gtk_version
|
||||
assert gtk_version_major == 2
|
||||
gtk_version_major, gtk_version_minor, gtk_version_release = gi.version_info
|
||||
assert gtk_version_major == 3
|
||||
|
||||
|
||||
def gtk_constant_name(group, value):
|
||||
"""
|
||||
Returns the (py)GTK+ name of a constant, given its group name
|
||||
"""
|
||||
group_response = {-1: 'gtk.RESPONSE_NONE',
|
||||
-2: 'gtk.RESPONSE_REJECT',
|
||||
-3: 'gtk.RESPONSE_ACCEPT',
|
||||
-4: 'gtk.RESPONSE_DELETE_EVENT',
|
||||
-5: 'gtk.RESPONSE_OK',
|
||||
-6: 'gtk.RESPONSE_CANCEL',
|
||||
-7: 'gtk.RESPONSE_CLOSE',
|
||||
-8: 'gtk.RESPONSE_YES',
|
||||
-9: 'gtk.RESPONSE_NO',
|
||||
-10: 'gtk.RESPONSE_APPLY',
|
||||
-11: 'gtk.RESPONSE_HELP'}
|
||||
group_response = {-1: 'Gtk.ResponseType.NONE',
|
||||
-2: 'Gtk.ResponseType.REJECT',
|
||||
-3: 'Gtk.ResponseType.ACCEPT',
|
||||
-4: 'Gtk.ResponseType.DELETE_EVENT',
|
||||
-5: 'Gtk.ResponseType.OK',
|
||||
-6: 'Gtk.ResponseType.CANCEL',
|
||||
-7: 'Gtk.ResponseType.CLOSE',
|
||||
-8: 'Gtk.ResponseType.YES',
|
||||
-9: 'Gtk.ResponseType.NO',
|
||||
-10: 'Gtk.ResponseType.APPLY',
|
||||
-11: 'Gtk.ResponseType.HELP'}
|
||||
|
||||
groups = {'response': group_response}
|
||||
|
||||
return groups.get(group, {}).get(value, 'Error: constant value not found')
|
||||
|
||||
|
||||
def gobject_register(klass):
|
||||
"""
|
||||
Register a given object by calling gobject.type_register.
|
||||
|
||||
Actually gobject.type_register is only called if the pygtk version in use
|
||||
is not 2.8 at least.
|
||||
"""
|
||||
if gtk_version_minor < 8:
|
||||
gobject.type_register(klass)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,29 +65,39 @@ higwidgets/higboxes.py
|
||||
|
||||
__all__ = ['HIGHBox', 'HIGVBox']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGBox(gtk.Box):
|
||||
class HIGBox(Gtk.Box):
|
||||
def _pack_noexpand_nofill(self, widget):
|
||||
self.pack_start(widget, expand=False, fill=False)
|
||||
self.pack_start(widget, False, False, 0)
|
||||
|
||||
def _pack_expand_fill(self, widget):
|
||||
self.pack_start(widget, expand=True, fill=True)
|
||||
self.pack_start(widget, True, True, 0)
|
||||
|
||||
def add(self, widget):
|
||||
# Make default packing arguments same as before (Gtk.Box has expand
|
||||
# set to False by default).
|
||||
self.pack_start(widget, True, True, 0)
|
||||
|
||||
|
||||
class HIGHBox(gtk.HBox, HIGBox):
|
||||
class HIGHBox(HIGBox):
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
gtk.HBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
pack_section_label = HIGBox._pack_noexpand_nofill
|
||||
pack_label = HIGBox._pack_noexpand_nofill
|
||||
pack_entry = HIGBox._pack_expand_fill
|
||||
|
||||
|
||||
class HIGVBox(gtk.VBox, HIGBox):
|
||||
class HIGVBox(HIGBox):
|
||||
def __init__(self, homogeneous=False, spacing=12):
|
||||
gtk.VBox.__init__(self, homogeneous, spacing)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL,
|
||||
homogeneous=homogeneous, spacing=spacing)
|
||||
|
||||
# Packs a widget as a line, so it doesn't expand vertically
|
||||
pack_line = HIGBox._pack_noexpand_nofill
|
||||
@@ -110,4 +119,4 @@ class HIGSpacer(HIGHBox):
|
||||
|
||||
|
||||
def hig_box_space_holder():
|
||||
return gtk.Label(" ")
|
||||
return Gtk.Label.new(" ")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -64,52 +63,57 @@ higwidgets/higbuttons.py
|
||||
button related classes
|
||||
"""
|
||||
|
||||
__all__ = ['HIGMixButton', 'HIGButton']
|
||||
__all__ = ['HIGButton', 'HIGToggleButton']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGMixButton (gtk.HBox):
|
||||
class HIGMixButton(Gtk.Box):
|
||||
def __init__(self, title, stock):
|
||||
gtk.HBox.__init__(self, False, 4)
|
||||
self.img = gtk.Image()
|
||||
self.img.set_from_stock(stock, gtk.ICON_SIZE_BUTTON)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL,
|
||||
homogeneous=False, spacing=4)
|
||||
self.img = Gtk.Image()
|
||||
self.img.set_from_stock(stock, Gtk.IconSize.BUTTON)
|
||||
|
||||
self.lbl = gtk.Label(title)
|
||||
self.lbl = Gtk.Label.new(title)
|
||||
|
||||
self.hbox1 = gtk.HBox(False, 2)
|
||||
self.hbox1 = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
|
||||
self.hbox1.set_homogeneous(False)
|
||||
self.hbox1.pack_start(self.img, False, False, 0)
|
||||
self.hbox1.pack_start(self.lbl, False, False, 0)
|
||||
|
||||
self.align = gtk.Alignment(0.5, 0.5, 0, 0)
|
||||
self.pack_start(self.align)
|
||||
self.pack_start(self.hbox1)
|
||||
self.align = Gtk.Alignment.new(0.5, 0.5, 0, 0)
|
||||
self.pack_start(self.align, True, True, 0)
|
||||
self.pack_start(self.hbox1, True, True, 0)
|
||||
|
||||
|
||||
class HIGButton (gtk.Button):
|
||||
class HIGButton(Gtk.Button):
|
||||
def __init__(self, title="", stock=None):
|
||||
if title and stock:
|
||||
gtk.Button.__init__(self)
|
||||
Gtk.Button.__init__(self)
|
||||
content = HIGMixButton(title, stock)
|
||||
self.add(content)
|
||||
elif title and not stock:
|
||||
gtk.Button.__init__(self, title)
|
||||
Gtk.Button.__init__(self, label=title)
|
||||
elif stock:
|
||||
gtk.Button.__init__(self, stock=stock)
|
||||
Gtk.Button.__init__(self, stock=stock)
|
||||
else:
|
||||
gtk.Button.__init__(self)
|
||||
Gtk.Button.__init__(self)
|
||||
|
||||
|
||||
class HIGToggleButton(gtk.ToggleButton):
|
||||
class HIGToggleButton(Gtk.ToggleButton):
|
||||
def __init__(self, title="", stock=None):
|
||||
if title and stock:
|
||||
gtk.ToggleButton.__init__(self)
|
||||
Gtk.ToggleButton.__init__(self)
|
||||
content = HIGMixButton(title, stock)
|
||||
self.add(content)
|
||||
elif title and not stock:
|
||||
gtk.ToggleButton.__init__(self, title)
|
||||
Gtk.ToggleButton.__init__(self, label=title)
|
||||
elif stock:
|
||||
gtk.ToggleButton.__init__(self, stock)
|
||||
Gtk.ToggleButton.__init__(self, stock=stock)
|
||||
self.set_use_stock(True)
|
||||
else:
|
||||
gtk.ToggleButton.__init__(self)
|
||||
Gtk.ToggleButton.__init__(self)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,23 +65,27 @@ higwidgets/higdialogs.py
|
||||
|
||||
__all__ = ['HIGDialog', 'HIGAlertDialog']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from gtkutils import gtk_version_minor
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGDialog(gtk.Dialog):
|
||||
class HIGDialog(Gtk.Dialog):
|
||||
"""
|
||||
HIGFied Dialog
|
||||
"""
|
||||
def __init__(self, title='', parent=None, flags=0, buttons=()):
|
||||
gtk.Dialog.__init__(self, title, parent, flags, buttons)
|
||||
Gtk.Dialog.__init__(self, title=title, parent=parent, flags=flags)
|
||||
self.set_border_width(5)
|
||||
self.vbox.set_border_width(2)
|
||||
self.vbox.set_spacing(6)
|
||||
|
||||
if buttons:
|
||||
self.add_buttons(*buttons)
|
||||
|
||||
class HIGAlertDialog(gtk.MessageDialog):
|
||||
|
||||
class HIGAlertDialog(Gtk.MessageDialog):
|
||||
"""
|
||||
HIGfied Alert Dialog.
|
||||
|
||||
@@ -90,15 +93,16 @@ class HIGAlertDialog(gtk.MessageDialog):
|
||||
http://developer.gnome.org/projects/gup/hig/2.0/windows-alert.html
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None, flags=0, type=gtk.MESSAGE_INFO,
|
||||
def __init__(self, parent=None, flags=0, type=Gtk.MessageType.INFO,
|
||||
# HIG mandates that every Alert should have an "affirmative
|
||||
# button that dismisses the alert and performs the action
|
||||
# suggested"
|
||||
buttons=gtk.BUTTONS_OK,
|
||||
buttons=Gtk.ButtonsType.OK,
|
||||
message_format=None,
|
||||
secondary_text=None):
|
||||
|
||||
gtk.MessageDialog.__init__(self, parent, flags, type, buttons)
|
||||
Gtk.MessageDialog.__init__(self, parent=parent, flags=flags,
|
||||
message_type=type, buttons=buttons)
|
||||
|
||||
self.set_resizable(False)
|
||||
|
||||
@@ -109,11 +113,7 @@ class HIGAlertDialog(gtk.MessageDialog):
|
||||
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:
|
||||
self.format_secondary_text(secondary_text)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -122,14 +122,14 @@ if __name__ == '__main__':
|
||||
|
||||
# HIGDialog
|
||||
d = HIGDialog(title='HIGDialog',
|
||||
buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
|
||||
dialog_label = HIGDialogLabel('A HIGDialogLabel on a HIGDialog')
|
||||
dialog_label.show()
|
||||
d.vbox.pack_start(dialog_label)
|
||||
d.vbox.pack_start(dialog_label, True, True, 0)
|
||||
|
||||
entry_label = HIGEntryLabel('A HIGEntryLabel on a HIGDialog')
|
||||
entry_label.show()
|
||||
d.vbox.pack_start(entry_label)
|
||||
d.vbox.pack_start(entry_label, True, True, 0)
|
||||
|
||||
d.run()
|
||||
d.destroy()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -64,11 +63,14 @@ higwidgets/higentries.py
|
||||
entries related classes
|
||||
"""
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
__all__ = ('HIGTextEntry', 'HIGPasswordEntry')
|
||||
|
||||
HIGTextEntry = gtk.Entry
|
||||
HIGTextEntry = Gtk.Entry
|
||||
|
||||
|
||||
class HIGPasswordEntry(HIGTextEntry):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,14 +65,17 @@ higwidgets/higexpanders.py
|
||||
|
||||
__all__ = ['HIGExpander']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from higboxes import HIGHBox, hig_box_space_holder
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .higboxes import HIGHBox, hig_box_space_holder
|
||||
|
||||
|
||||
class HIGExpander(gtk.Expander):
|
||||
class HIGExpander(Gtk.Expander):
|
||||
def __init__(self, label):
|
||||
gtk.Expander.__init__(self)
|
||||
Gtk.Expander.__init__(self)
|
||||
|
||||
self.set_use_markup(True)
|
||||
self.set_label(label)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,18 +65,21 @@ higwidgets/higframe.py
|
||||
|
||||
__all__ = ['HIGFrame']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGFrame(gtk.Frame):
|
||||
class HIGFrame(Gtk.Frame):
|
||||
"""
|
||||
Frame without border with bold label.
|
||||
"""
|
||||
def __init__(self, label=None):
|
||||
gtk.Frame.__init__(self)
|
||||
Gtk.Frame.__init__(self)
|
||||
|
||||
self.set_shadow_type(gtk.SHADOW_NONE)
|
||||
self._flabel = gtk.Label()
|
||||
self.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
self._flabel = Gtk.Label()
|
||||
self._set_label(label)
|
||||
self.set_label_widget(self._flabel)
|
||||
|
||||
@@ -86,20 +88,20 @@ class HIGFrame(gtk.Frame):
|
||||
|
||||
# Demo
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
|
||||
hframe = HIGFrame("Sample HIGFrame")
|
||||
aalign = gtk.Alignment(0, 0, 0, 0)
|
||||
aalign = Gtk.Alignment.new(0, 0, 0, 0)
|
||||
aalign.set_padding(12, 0, 24, 0)
|
||||
abox = gtk.VBox()
|
||||
abox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
aalign.add(abox)
|
||||
hframe.add(aalign)
|
||||
w.add(hframe)
|
||||
|
||||
for i in xrange(5):
|
||||
abox.pack_start(gtk.Label("Sample %d" % i), False, False, 3)
|
||||
for i in range(5):
|
||||
abox.pack_start(Gtk.Label.new("Sample %d" % i), False, False, 3)
|
||||
|
||||
w.connect('destroy', lambda d: gtk.main_quit())
|
||||
w.connect('destroy', lambda d: Gtk.main_quit())
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -68,45 +67,49 @@ __all__ = [
|
||||
'HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel', 'HIGDialogLabel'
|
||||
]
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
|
||||
class HIGSectionLabel(gtk.Label):
|
||||
class HIGSectionLabel(Gtk.Label):
|
||||
"""
|
||||
Bold label, used to define sections
|
||||
"""
|
||||
def __init__(self, text=None):
|
||||
gtk.Label.__init__(self)
|
||||
Gtk.Label.__init__(self)
|
||||
if text:
|
||||
self.set_markup("<b>%s</b>" % (text))
|
||||
self.set_justify(gtk.JUSTIFY_LEFT)
|
||||
self.set_alignment(0, 0.50)
|
||||
self.set_justify(Gtk.Justification.LEFT)
|
||||
self.props.xalign = 0
|
||||
self.props.yalign = 0.5
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class HIGHintSectionLabel(gtk.HBox, object):
|
||||
class HIGHintSectionLabel(Gtk.Box, object):
|
||||
"""
|
||||
Bold label used to define sections, with a little icon that shows up a hint
|
||||
when mouse is over it.
|
||||
"""
|
||||
def __init__(self, text=None, hint=None):
|
||||
gtk.HBox.__init__(self)
|
||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.label = HIGSectionLabel(text)
|
||||
self.hint = Hint(hint)
|
||||
|
||||
self.pack_start(self.label, False, False)
|
||||
self.pack_start(self.label, False, False, 0)
|
||||
self.pack_start(self.hint, False, False, 5)
|
||||
|
||||
|
||||
class Hint(gtk.EventBox, object):
|
||||
class Hint(Gtk.EventBox, object):
|
||||
def __init__(self, hint):
|
||||
gtk.EventBox.__init__(self)
|
||||
Gtk.EventBox.__init__(self)
|
||||
self.hint = hint
|
||||
|
||||
self.hint_image = gtk.Image()
|
||||
self.hint_image.set_from_stock(
|
||||
gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||
self.hint_image = Gtk.Image()
|
||||
self.hint_image.set_from_icon_name(
|
||||
"dialog-information", Gtk.IconSize.SMALL_TOOLBAR)
|
||||
|
||||
self.add(self.hint_image)
|
||||
|
||||
@@ -117,23 +120,27 @@ class Hint(gtk.EventBox, object):
|
||||
hint_window.show_all()
|
||||
|
||||
|
||||
class HintWindow(gtk.Window):
|
||||
class HintWindow(Gtk.Window):
|
||||
def __init__(self, hint):
|
||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||
self.set_position(gtk.WIN_POS_MOUSE)
|
||||
bg_color = gtk.gdk.color_parse("#fbff99")
|
||||
Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
|
||||
self.set_position(Gtk.WindowPosition.MOUSE)
|
||||
self.set_resizable(False)
|
||||
|
||||
self.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||
bg_color = Gdk.RGBA()
|
||||
bg_color.parse("#fbff99")
|
||||
self.override_background_color(Gtk.StateFlags.NORMAL, bg_color)
|
||||
|
||||
self.event = gtk.EventBox()
|
||||
self.event.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||
self.event = Gtk.EventBox()
|
||||
self.event.override_background_color(Gtk.StateFlags.NORMAL, bg_color)
|
||||
self.event.set_border_width(10)
|
||||
self.event.connect("button-press-event", self.close)
|
||||
|
||||
self.hint_label = gtk.Label(hint)
|
||||
self.hint_label = Gtk.Label.new(hint)
|
||||
self.hint_label.set_use_markup(True)
|
||||
self.hint_label.set_line_wrap(True)
|
||||
self.hint_label.set_alignment(0.0, 0.5)
|
||||
self.hint_label.set_max_width_chars(52)
|
||||
self.hint_label.props.xalign = 0
|
||||
self.hint_label.props.yalign = 0.5
|
||||
|
||||
self.event.add(self.hint_label)
|
||||
self.add(self.event)
|
||||
@@ -142,33 +149,34 @@ class HintWindow(gtk.Window):
|
||||
self.destroy()
|
||||
|
||||
|
||||
class HIGEntryLabel(gtk.Label):
|
||||
class HIGEntryLabel(Gtk.Label):
|
||||
"""
|
||||
Simple label, like the ones used to label entries
|
||||
"""
|
||||
def __init__(self, text=None):
|
||||
gtk.Label.__init__(self, text)
|
||||
self.set_justify(gtk.JUSTIFY_LEFT)
|
||||
self.set_alignment(0, 0.50)
|
||||
Gtk.Label.__init__(self, label=text)
|
||||
self.set_justify(Gtk.Justification.LEFT)
|
||||
self.props.xalign = 0
|
||||
self.props.yalign = 0.5
|
||||
self.set_use_markup(True)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
|
||||
class HIGDialogLabel(gtk.Label):
|
||||
class HIGDialogLabel(Gtk.Label):
|
||||
"""
|
||||
Centered, line-wrappable label, usually used on dialogs.
|
||||
"""
|
||||
def __init__(self, text=None):
|
||||
gtk.Label.__init__(self, text)
|
||||
self.set_justify(gtk.JUSTIFY_CENTER)
|
||||
Gtk.Label.__init__(self, label=text)
|
||||
self.set_justify(Gtk.Justification.CENTER)
|
||||
self.set_use_markup(True)
|
||||
self.set_line_wrap(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
w = gtk.Window()
|
||||
w = Gtk.Window()
|
||||
h = HIGHintSectionLabel("Label", "Hint")
|
||||
w.add(h)
|
||||
w.connect("delete-event", lambda x, y: gtk.main_quit())
|
||||
w.connect("delete-event", lambda x, y: Gtk.main_quit())
|
||||
w.show_all()
|
||||
|
||||
gtk.main()
|
||||
Gtk.main()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,12 +65,15 @@ higwidgets/higlogindialog.py
|
||||
|
||||
__all__ = ['HIGLoginDialog']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from higdialogs import HIGDialog
|
||||
from higlabels import HIGEntryLabel
|
||||
from higtables import HIGTable
|
||||
from higentries import HIGTextEntry, HIGPasswordEntry
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .higdialogs import HIGDialog
|
||||
from .higlabels import HIGEntryLabel
|
||||
from .higtables import HIGTable
|
||||
from .higentries import HIGTextEntry, HIGPasswordEntry
|
||||
|
||||
|
||||
class HIGLoginDialog(HIGDialog):
|
||||
@@ -79,8 +81,8 @@ class HIGLoginDialog(HIGDialog):
|
||||
A dialog that asks for basic login information (username / password)
|
||||
"""
|
||||
def __init__(self, title='Login',
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)):
|
||||
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)):
|
||||
HIGDialog.__init__(self, title, buttons=buttons)
|
||||
|
||||
self.username_label = HIGEntryLabel("Username:")
|
||||
@@ -98,8 +100,8 @@ class HIGLoginDialog(HIGDialog):
|
||||
self.username_password_table.attach_entry(self.password_entry,
|
||||
1, 2, 1, 2)
|
||||
|
||||
self.vbox.pack_start(self.username_password_table, False, False)
|
||||
self.set_default_response(gtk.RESPONSE_ACCEPT)
|
||||
self.vbox.pack_start(self.username_password_table, False, False, 0)
|
||||
self.set_default_response(Gtk.ResponseType.ACCEPT)
|
||||
|
||||
def run(self):
|
||||
self.show_all()
|
||||
@@ -112,5 +114,5 @@ if __name__ == '__main__':
|
||||
# HIGLoginDialog
|
||||
d = HIGLoginDialog()
|
||||
response_value = d.run()
|
||||
print gtk_constant_name('response', response_value)
|
||||
print(gtk_constant_name('response', response_value))
|
||||
d.destroy()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -58,26 +57,28 @@
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import gi
|
||||
|
||||
from higboxes import HIGHBox
|
||||
from higbuttons import HIGButton
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
from .higboxes import HIGHBox
|
||||
from .higbuttons import HIGButton
|
||||
|
||||
|
||||
class HIGNotebook(gtk.Notebook):
|
||||
class HIGNotebook(Gtk.Notebook):
|
||||
def __init__(self):
|
||||
gtk.Notebook.__init__(self)
|
||||
Gtk.Notebook.__init__(self)
|
||||
self.popup_enable()
|
||||
|
||||
|
||||
class HIGClosableTabLabel(HIGHBox):
|
||||
__gsignals__ = {
|
||||
'close-clicked': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
|
||||
'close-clicked': (GObject.SignalFlags.RUN_LAST, GObject.TYPE_NONE, ())
|
||||
}
|
||||
|
||||
def __init__(self, label_text=""):
|
||||
gobject.GObject.__init__(self)
|
||||
GObject.GObject.__init__(self)
|
||||
#HIGHBox.__init__(self, spacing=4)
|
||||
|
||||
self.label_text = label_text
|
||||
@@ -86,12 +87,12 @@ class HIGClosableTabLabel(HIGHBox):
|
||||
#self.property_map = {"label_text" : self.label.get_label}
|
||||
|
||||
def __create_widgets(self):
|
||||
self.label = gtk.Label(self.label_text)
|
||||
self.close_image = gtk.Image()
|
||||
self.close_image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
|
||||
self.label = Gtk.Label.new(self.label_text)
|
||||
self.close_image = Gtk.Image()
|
||||
self.close_image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.BUTTON)
|
||||
self.close_button = HIGButton()
|
||||
self.close_button.set_size_request(20, 20)
|
||||
self.close_button.set_relief(gtk.RELIEF_NONE)
|
||||
self.close_button.set_relief(Gtk.ReliefStyle.NONE)
|
||||
self.close_button.set_focus_on_click(False)
|
||||
self.close_button.add(self.close_image)
|
||||
|
||||
@@ -124,6 +125,6 @@ class HIGClosableTabLabel(HIGHBox):
|
||||
def set_label(self, label):
|
||||
self.label.set_text(label)
|
||||
|
||||
gobject.type_register(HIGClosableTabLabel)
|
||||
GObject.type_register(HIGClosableTabLabel)
|
||||
|
||||
HIGAnimatedTabLabel = HIGClosableTabLabel
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,9 +65,12 @@ higwidgets/higprogressbars.py
|
||||
|
||||
__all__ = ['HIGLabeledProgressBar']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
from higboxes import HIGHBox
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .higboxes import HIGHBox
|
||||
|
||||
|
||||
class HIGLabeledProgressBar(HIGHBox):
|
||||
@@ -77,7 +79,7 @@ class HIGLabeledProgressBar(HIGHBox):
|
||||
if label:
|
||||
self.label = HIGEntryLabel(label)
|
||||
self.pack_label(self.label)
|
||||
self.progress_bar = gtk.ProgressBar()
|
||||
self.progress_bar = Gtk.ProgressBar()
|
||||
self.progress_bar.set_size_request(80, 16)
|
||||
self.pack_label(self.progress_bar)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ***********************IMPORTANT NMAP LICENSE TERMS************************
|
||||
# * *
|
||||
@@ -66,11 +65,14 @@ higwidgets/higscrollers.py
|
||||
|
||||
__all__ = ['HIGScrolledWindow']
|
||||
|
||||
import gtk
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
class HIGScrolledWindow(gtk.ScrolledWindow):
|
||||
class HIGScrolledWindow(Gtk.ScrolledWindow):
|
||||
def __init__(self):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
Gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
||||
self.set_border_width(5)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user