Changeset 789
- Timestamp:
- 06/12/07 04:45:14 (6 years ago)
- Location:
- branch/ggpolo
- Files:
-
- 3 modified
-
umitDB/retrieve.py (modified) (1 diff)
-
umitInventory/new-sample/new-sample-demo.py (modified) (5 diffs)
-
umitInventory/viewer.py (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/ggpolo/umitDB/retrieve.py
r767 r789 360 360 361 361 return fts 362 363 364 """ 365 Missing (c1) for port data retrieve: ostype in service_info. 366 Reason: NmapParser doesn't handle this yet. 367 """ 368 369 def get_portid_and_fks_for_host_from_db(self, host): 370 """ 371 Get portid and fks from port table, for a host. 372 """ 373 debug("Getting portid and foreign keys for host id %d from \ 374 table port.." % host) 375 376 pdata = self.cursor.execute("SELECT portid, fk_service_info, \ 377 fk_protocol, fk_port_state FROM port \ 378 JOIN _host_port ON \ 379 (_host_port.fk_port=port.pk) \ 380 WHERE _host_port.fk_host=?", 381 (host, )).fetchall() 382 383 return pdata 384 385 def get_port_data_for_pdata_from_db(self, protocol_id, port_state_id, 386 service_info_id): 387 """ 388 Get port data based on data returned from 389 get_portid_and_fks_for_host_from_db 390 """ 391 debug("Getting port data for pdata..") 392 393 fullpdata = self.cursor.execute("SELECT protocol.name, \ 394 port_state.state, service_info.product, \ 395 service_info.version, service_info.extrainfo, \ 396 service_info.method, service_info.conf, \ 397 service_name.name FROM protocol, port_state, \ 398 service_info, service_name WHERE protocol.pk = ? AND \ 399 port_state.pk = ? AND service_info.pk = ? AND \ 400 service_name.pk = service_info.fk_service_name", 401 (protocol_id, port_state_id, service_info_id)).fetchall()[0] 402 403 return fullpdata 404 405 """ 406 End (c1) 407 """ 408 409 def get_extraports_data_for_host_from_db(self, host_id): 410 """ 411 Get extraport data for host id 412 """ 413 debug("Getting extraports data for host id %d" % host_id) 414 415 epdata = self.cursor.execute("SELECT extraports.count, \ 416 port_state.state FROM extraports, port_state \ 417 WHERE extraports.fk_host = ? AND \ 418 port_state.pk = extraports.fk_port_state", 419 (host_id, )).fetchall()[0] 420 return epdata 362 421 363 422 -
branch/ggpolo/umitInventory/new-sample/new-sample-demo.py
r785 r789 691 691 692 692 for btn in self.tlbox: 693 self.goodp.append((x, y - (btn.evts['good'] * 11.55)))694 self.badp.append((x, y - (btn.evts['bad'] * 11.55)))695 self.nonep.append((x, y - (btn.evts['none'] * 11.55)))696 self.unknownp.append((x, y - (btn.evts['unknown'] * 11.55)))693 self.goodp.append((x, y - (btn.evts['good'] * (end_y/9.0)) + 1)) 694 self.badp.append((x, y - (btn.evts['bad'] * (end_y/9.0)) + 1)) 695 self.nonep.append((x, y - (btn.evts['none'] * (end_y/9.0)) + 1)) 696 self.unknownp.append((x, y - (btn.evts['unknown'] * (end_y/9.0)) + 1)) 697 697 698 698 x += vdivs … … 716 716 cr.rel_line_to(0, end_y + 10) 717 717 cr.stroke() 718 cr.move_to(start_x - 10, start_y + end_y + 20) 719 cr.set_source_rgba(0, 0, 0, 0.6) 720 cr.show_text('Jan') 718 t = 'Jan' 719 x_bearing, y_bearing, width, height, x_advance, y_advance = cr.text_extents(t) 720 cr.move_to(start_x - width/2, start_y + end_y + 20) 721 cr.set_source_rgba(0, 0, 0, 0.6) 722 cr.show_text(t) 721 723 722 724 cr.set_source_rgb(0, 0, 0) … … 787 789 cr.rel_line_to(0, 10) 788 790 cr.stroke() 789 cr.move_to(start_v - 12, end_y + 30) 790 cr.show_text(months[h][:3]) 791 # need to correctly align this 792 t = months[h][:3] 793 x_bearing, y_bearing, width, height, x_advance, y_advance = cr.text_extents(t) 794 cr.move_to(start_v - width/2, end_y + 30) 795 cr.show_text(t) 791 796 792 797 start_v += vdivs … … 796 801 if sel != -1: 797 802 self.temp_level = 0 798 #self.painting_sel = True799 803 self.painting_sel = gobject.timeout_add(50, self._progressive_sel, sel, area) 800 #print self.painting_sel801 804 return True 802 805 return False … … 1091 1094 1092 1095 def do_size_request(self, requisition): 1093 requisition.width = 101094 requisition.height = 101096 requisition.width = 360 1097 requisition.height = 90 1095 1098 1096 1099 def do_size_allocate(self, allocation): -
branch/ggpolo/umitInventory/viewer.py
r777 r789 36 36 import umitInventory.tl as tl 37 37 38 from samplentl import samplentl_box 39 38 40 try: 39 41 umitdb = Path.umitdb_ng … … 274 276 self.add_accel_group(self.main_accel_group) 275 277 278 self.viewernb = HIGNotebook() 279 276 280 self.invdb = InventoryRetrieve(umitdb) 277 281 self.invtree = InventoryTree(self) … … 281 285 self.invnbpages_objects = [ ] 282 286 287 self.newtl = samplentl_box() 288 self.newtl.show_all() 289 290 """ 283 291 self.timeline = tl.main(testing_mode=True, zoom=3, 284 292 cell_border=False, border_on_focus=False, … … 290 298 self.uparrow = tl.arrow(-3, self.timeline) # up arrow (zoom out) 291 299 self.tl_dtitle = gtk.Label() # timeline title 300 """ 292 301 293 302 # statusbar … … 297 306 298 307 # tooltips 308 """ 299 309 self.tooltips = gtk.Tooltips() 300 310 self.tooltips.set_tip(self.tlyah, _("Timeline: You are here!")) … … 302 312 self.tooltips.set_tip(self.rarrow, _("Go to the next date.")) 303 313 self.tooltips.set_tip(self.timeline, _("TimeLine")) 314 """ 304 315 305 316 self._fill_tree() … … 307 318 self.__set_props() 308 319 self.__do_layout() 309 320 310 321 self.connect('destroy', self._exit_ni) 311 322 self.connect('inventory-activated', self._inventory_activated) 312 self.timeline.connect('date-change-notify', self._tl_date_changed) 313 self.timeline.connect('range-change-notify', self._tl_date_changed) 314 self.timeline.connect('scroll_event', self._tl_scroll_event) 315 316 self._tl_date_changed(None) 317 323 self.connect('realize', self.on_realize) 324 #self.timeline.connect('date-change-notify', self._tl_date_changed) 325 #self.timeline.connect('range-change-notify', self._tl_date_changed) 326 #self.timeline.connect('scroll_event', self._tl_scroll_event) 327 328 #self._tl_date_changed(None) 329 330 def on_realize(self, event): 331 self.viewernb.set_current_page(0) 318 332 319 333 def _tl_date_changed(self, event): … … 386 400 387 401 402 """ 388 403 def _tl_view_legend(self, event): 389 """ 390 Show up TimeLine legend. 391 """ 404 #Show up TimeLine legend. 392 405 dlg = LegendDlg(self.timeline) 393 406 dlg.show_all() 394 407 395 408 409 396 410 def _set_yahrange(self, min, max): 397 """ 398 Set new TimeLine year range. 399 """ 411 #Set new TimeLine year range. 400 412 miny = min.year - 1 401 413 maxy = max.year + 1 … … 404 416 self.timeline.year_range = (miny, maxy) 405 417 self.timeline.emit('range-change-notify') 418 """ 406 419 407 420 … … 532 545 content = p.get_nth_page(p.get_n_pages() - 1) 533 546 534 lstore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) 535 536 # insert scan finish date and host status 547 lstore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, 548 gobject.TYPE_STRING, gobject.TYPE_STRING) 549 550 # fill liststore 537 551 host_count = 0 538 552 for item in finish_data: 539 553 iter = lstore.append() 540 554 lstore.set(iter, 0, item[1]) 541 555 556 try: 557 base_hosts_data[host_count][0] 558 except: 559 lstore.set(iter, 1, "down") 560 continue 561 542 562 if base_hosts_data[host_count][0] == item[0]: 543 563 lstore.set(iter, 1, "up") 564 # get port data for this host 565 pdata = self.invdb.get_portid_and_fks_for_host_from_db(base_hosts_data[host_count][1]) 566 temp = "" 567 for pd in pdata: 568 fpd = self.invdb.get_port_data_for_pdata_from_db(pd[2], 569 pd[3], 570 pd[1]) 571 if len(pdata) > 1: 572 temp += "Port No: %s, Data: %s\n" % (pd[0], fpd) 573 else: 574 temp += "Port No: %s, Data: %s" % (pd[0], fpd) 575 576 lstore.set(iter, 2, temp) 577 578 # get extraports data for this host 579 epdata = self.invdb.get_extraports_data_for_host_from_db(base_hosts_data[host_count][1]) 580 lstore.set(iter, 3, "Count: %d, State: %s" % (epdata[0], epdata[1])) 581 544 582 host_count += 1 545 583 else: … … 558 596 column = gtk.TreeViewColumn(_("Host status"), 559 597 gtk.CellRendererText(), text=1) 598 treeview.append_column(column) 599 600 # column for host ports (this will be broken in several parts) 601 column = gtk.TreeViewColumn(_("Host ports"), 602 gtk.CellRendererText(), text=2) 603 treeview.append_column(column) 604 605 # column for host extraports (" ") 606 column = gtk.TreeViewColumn(_("Host extraports"), 607 gtk.CellRendererText(), text=3) 560 608 treeview.append_column(column) 561 609 … … 607 655 608 656 # Adjusts timeline range based on min and max timestamps from scans. 609 if timestamps:610 self._set_yahrange(min(timestamps), max(timestamps))657 #if timestamps: 658 # self._set_yahrange(min(timestamps), max(timestamps)) 611 659 612 660 self.invtree.treeview.expand_all() … … 632 680 ("File", None, _("_File"), None), 633 681 ("Edit", None, _("_Edit" ), None), 634 ("TimeLine", None, _("_Timeline"), None),682 #("TimeLine", None, _("_Timeline"), None), 635 683 ("ToolbarOpt", None, _("Tool_bar"), None), 636 684 ("InvTabs", None, _("_Tabs"), None), … … 647 695 648 696 # Edit/Timeline 649 ("ViewLegend", None, _("View _Legend"), None,650 _("Show up Legend for Timeline"), self._tl_view_legend),651 652 ("ZoomIn", gtk.STOCK_ZOOM_IN, _("Zoom _In"), None,653 _("Zoom In one level"), self._tl_zoom_in),654 655 ( "ZoomOut", gtk.STOCK_ZOOM_OUT, _("Zoom _Out"), None,656 _("Zoom Out one level"), self._tl_zoom_out),697 #("ViewLegend", None, _("View _Legend"), None, 698 # _("Show up Legend for Timeline"), self._tl_view_legend), 699 700 #("ZoomIn", gtk.STOCK_ZOOM_IN, _("Zoom _In"), None, 701 # _("Zoom In one level"), self._tl_zoom_in), 702 703 #( "ZoomOut", gtk.STOCK_ZOOM_OUT, _("Zoom _Out"), None, 704 # _("Zoom Out one level"), self._tl_zoom_out), 657 705 658 706 # Edit/ToolbarOpt … … 680 728 self.write_tips), 681 729 # Edit/Timeline 682 ("ShowTimeline", None, 683 _("Show _Timeline"), None, 684 _("Show/Hide Timeline"), 685 self._opt_timeline, 686 True), 687 ("ShowYAH", None, 688 _("Show \"You Are Here!\""), None, 689 _("Show/Hide \"You Are Here!\""), 690 self._opt_tlyah, 691 True), 730 #("ShowTimeline", None, 731 # _("Show _Timeline"), None, 732 # _("Show/Hide Timeline"), 733 # self._opt_timeline, 734 # True), 735 #("ShowYAH", None, 736 # _("Show \"You Are Here!\""), None, 737 # _("Show/Hide \"You Are Here!\""), 738 # self._opt_tlyah, 739 # True), 740 692 741 # Edit/Notebooks 693 742 ("TabCloseBtn", None, … … 731 780 </toolbar> 732 781 """ 782 783 default_ui = """ 784 <menubar> 785 <menu action='File'> 786 <menuitem action='CloseHostTab' /> 787 <menuitem action='CloseInvTab' /> 788 <menuitem action='Quit' /> 789 </menu> 790 <menu action='Edit'> 791 <menu action='ToolbarOpt'> 792 <menuitem action='TBIcon' /> 793 <menuitem action='TBText' /> 794 <menuitem action='TBBoth' /> 795 </menu> 796 <menu action='InvTabs'> 797 <menuitem action='TabCloseBtn' /> 798 </menu> 799 <menuitem action='ShowTips' /> 800 </menu> 801 </menubar> 802 """ 733 803 734 804 self.main_action_group.add_actions(main_actions) … … 756 826 Set window properties. 757 827 """ 758 self.set_title(_("UMIT Network Inventory 0.0.2.2")) 828 self.set_title(_("UMIT Network Inventory 0.0.2.3")) 829 # a size for testing 830 self.set_position(gtk.WIN_POS_CENTER) 831 width, height = gtk.gdk.get_default_root_window().get_size() 832 self.set_default_size((width*3)/4, (height*3)/4) 759 833 760 834 … … 773 847 main_vbox.pack_start(menubar, False, False, 0) 774 848 849 """ 775 850 toolbar = self.ui_manager.get_widget("/Toolbar") 776 851 toolbar.set_style(gtk.TOOLBAR_ICONS) 777 852 main_vbox.pack_start(toolbar, False, False, 0) 853 """ 778 854 779 855 left_pane_box = gtk.VBox() 780 856 left_pane_box.pack_start(self.invtree, True, True, 0) 781 857 858 """ 782 859 self.yah_hb = gtk.HandleBox() 783 860 self.yah_hb.add(self.tlyah) 784 861 self.yah_hb.set_handle_position(gtk.POS_TOP) 785 862 left_pane_box.pack_end(self.yah_hb, False, False, 0) 863 """ 786 864 787 865 main_hpaned.add1(left_pane_box) … … 789 867 790 868 # align left and right arrow with timeline height 869 """ 791 870 tlbox2 = gtk.HBox() 792 871 align = gtk.Alignment(0, 1, 0, 0.5) … … 803 882 804 883 tlbox.pack_start(tlbox2, True, True, 0) 884 """ 805 885 806 886 # place inventories notebook in a scrolledwindow … … 810 890 nb_tl_hpaned.pack1(nbscroll, True, False) 811 891 812 main_vbox.pack_start(self.tl_dtitle, False, False, 6) 813 main_vbox.pack_start(tlbox, False, False, 0) 814 main_vbox.pack_start(main_hpaned, True, True, 0) 892 #main_vbox.pack_start(self.tl_dtitle, False, False, 6) 893 #main_vbox.pack_start(tlbox, False, False, 0) 894 895 self.viewernb.append_page(main_hpaned, gtk.Label(_(" Historic "))) 896 897 self.viewernb.append_page(self.newtl, gtk.Label(_(" Timeline "))) 898 899 #main_vbox.pack_start(main_hpaned, True, True, 0) 900 main_vbox.pack_start(self.viewernb, True, True, 0) 815 901 main_vbox.pack_end(self.statusbar, False, False, 0) 816 902
