class TopologyPage(HIGVBox): def __init__(self, inventory): HIGVBox.__init__(self) self.set_border_width(6) self.set_spacing(4) self.network_inventory = inventory self._create_widgets() self._pack_widgets() def _create_widgets(self): self.rn_hbox = gtk.HBox() self.rn_hbox.set_spacing(4) self.rn_vbox = gtk.VBox() # RadialNet's widgets self.radialnet = RadialNet(LAYOUT_WEIGHTED) self.control = ControlWidget(self.radialnet) self.fisheye = ControlFisheye(self.radialnet) self.rn_toolbar = Toolbar(self.radialnet, self, self.control, self.fisheye) self.display_panel = 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")) show_button.connect("clicked", self.show_anyway) self.slow_vbox.pack_start(show_button, False, False) self.slow_vbox.show_all() self.slow_vbox.set_no_show_all(True) self.slow_vbox.hide() 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_vbox.pack_start(self.rn_hbox, True, True) self.rn_vbox.pack_start(self.fisheye, False) self.pack_start(self.rn_toolbar, False, False) self.pack_start(self.rn_vbox, True, True) self.display_panel.pack_start(self.slow_vbox, True, False) self.display_panel.pack_start(self.radialnet, True, True) def add_scan(self, scan): """Parses a given XML file and adds the parsed result to the network inventory.""" self.network_inventory.add_scan(scan) self.update_radialnet() def update_radialnet(self): """Creates a graph from network inventory's host list and displays it.""" hosts_up = self.network_inventory.get_hosts_up() self.slow_label.set_text( _("""\ Topology is disabled because too many hosts can cause it to run slowly. The limit is %d hosts and there are %d.\ """ % (SLOW_LIMIT, len(hosts_up)))) if len(hosts_up) <= SLOW_LIMIT: self.radialnet.show() self.slow_vbox.hide() self.update_radialnet_unchecked() else: self.radialnet.hide() self.slow_vbox.show() def update_radialnet_unchecked(self): hosts_up = self.network_inventory.get_hosts_up() graph = make_graph_from_hosts(hosts_up) self.radialnet.set_empty() self.radialnet.set_graph(graph) self.radialnet.show() def show_anyway(self, widget): self.radialnet.show() self.slow_vbox.hide() self.update_radialnet_unchecked()
class Application(BWMainWindow): """ """ def __init__(self): """ """ BWMainWindow.__init__(self) self.set_default_size(DIMENSION[0], DIMENSION[1]) self.set_icon(Pixmaps().get_pixbuf('logo')) self.__create_widgets() def __create_widgets(self): """ """ self.__hbox = BWHBox(spacing=0) self.__vbox = BWVBox(spacing=0) self.__radialnet = RadialNet(LAYOUT_WEIGHTED) self.__control = ControlWidget(self.__radialnet) self.__fisheye = ControlFisheye(self.__radialnet) self.__toolbar = Toolbar(self.__radialnet, self, self.__control, self.__fisheye) self.__statusbar = BWStatusbar() self.__hbox.bw_pack_start_expand_fill(self.__radialnet) self.__hbox.bw_pack_start_noexpand_nofill(self.__control) self.__vbox.bw_pack_start_noexpand_nofill(self.__toolbar) self.__vbox.bw_pack_start_expand_fill(self.__hbox) self.__vbox.bw_pack_start_noexpand_nofill(self.__fisheye) self.__vbox.bw_pack_start_noexpand_nofill(self.__statusbar) self.add(self.__vbox) self.set_title(" ".join([INFO['name'], INFO['version']])) self.set_position(gtk.WIN_POS_CENTER) self.show_all() self.connect('destroy', gtk.main_quit) self.__radialnet.set_no_show_all(True) self.__control.set_no_show_all(True) self.__fisheye.set_no_show_all(True) self.__radialnet.hide() self.__control.hide() self.__fisheye.hide() self.__toolbar.disable_controls() def parse_nmap_xml_file(self, file): """ """ try: self.__parser = XMLReader(file) self.__parser.parse() except: text = 'It is not possible open file: %s.' % file alert = BWAlertDialog(self, primary_text='Error opening file.', secondary_text=text) alert.show_all() return False self.__radialnet.set_empty() self.__radialnet.set_graph(make_graph_from_nmap_parser(self.__parser)) self.__radialnet.show() self.__toolbar.enable_controls() return True def start(self): """ """ gtk.main()
class TopologyPage(HIGVBox): def __init__(self, inventory): HIGVBox.__init__(self) self.set_border_width(6) self.set_spacing(4) self.network_inventory = inventory self._create_widgets() self._pack_widgets() def _create_widgets(self): self.rn_hbox = gtk.HBox() self.rn_hbox.set_spacing(4) self.rn_vbox = gtk.VBox() # RadialNet's widgets self.radialnet = RadialNet(LAYOUT_WEIGHTED) self.control = ControlWidget(self.radialnet) self.fisheye = ControlFisheye(self.radialnet) self.rn_toolbar = Toolbar(self.radialnet, self, self.control, self.fisheye) self.display_panel = 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")) show_button.connect("clicked", self.show_anyway) self.slow_vbox.pack_start(show_button, False, False) self.slow_vbox.show_all() self.slow_vbox.set_no_show_all(True) self.slow_vbox.hide() 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_vbox.pack_start(self.rn_hbox, True, True) self.rn_vbox.pack_start(self.fisheye, False) self.pack_start(self.rn_toolbar, False, False) self.pack_start(self.rn_vbox, True, True) self.display_panel.pack_start(self.slow_vbox, True, False) self.display_panel.pack_start(self.radialnet, True, True) def add_scan(self, scan): """Parses a given XML file and adds the parsed result to the network inventory.""" self.network_inventory.add_scan(scan) self.update_radialnet() def update_radialnet(self): """Creates a graph from network inventory's host list and displays it.""" hosts_up = self.network_inventory.get_hosts_up() self.slow_label.set_text(_("""\ Topology is disabled because too many hosts can cause it to run slowly. The limit is %d hosts and there are %d.\ """ % (SLOW_LIMIT, len(hosts_up)))) if len(hosts_up) <= SLOW_LIMIT: self.radialnet.show() self.slow_vbox.hide() self.update_radialnet_unchecked() else: self.radialnet.hide() self.slow_vbox.show() def update_radialnet_unchecked(self): hosts_up = self.network_inventory.get_hosts_up() graph = make_graph_from_hosts(hosts_up) self.radialnet.set_empty() self.radialnet.set_graph(graph) self.radialnet.show() def show_anyway(self, widget): self.radialnet.show() self.slow_vbox.hide() self.update_radialnet_unchecked()