Changeset 949

Show
Ignore:
Timestamp:
07/05/07 19:10:49 (6 years ago)
Author:
ggpolo
Message:

small fix in changeslist.py for checking host availability, fix for checking database updates, added new cursor (dict_factory) for umitDB

Location:
branch/ggpolo
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/umitDB/connection.py

    r926 r949  
    2525from umitDB._database import database 
    2626from umitDB.utils import debug 
     27 
     28def dict_factory(cursor, row): 
     29    """ 
     30    Convert a standard row to a dict. 
     31    """ 
     32    d = {} 
     33 
     34    for idx, col in enumerate(cursor.description): 
     35        d[col[0]] = row[idx] 
     36         
     37    return d 
     38 
    2739 
    2840class ConnectDB: 
     
    5567     
    5668     
     69    def use_dict_cursor(self): 
     70        """ 
     71        Change to dict_factory cursor. 
     72        """ 
     73        self.cursor.close() 
     74        self.conn.row_factory = dict_factory 
     75        self.cursor = self.conn.cursor() 
     76 
     77         
     78    def use_standard_cursor(self): 
     79        """ 
     80        Change to standard cursor. 
     81        """ 
     82        self.cursor.close() 
     83        self.conn.row_factory = None 
     84        self.cursor = self.conn.cursor() 
     85         
     86     
    5787    def get_id_for(self, table_name): 
    5888        """ 
  • branch/ggpolo/umitDB/retrieve.py

    r927 r949  
    422422        debug("Getting port data for pdata..") 
    423423         
    424         fullpdata = self.cursor.execute("SELECT protocol.name, \ 
     424        fullpdata = self.cursor.execute("SELECT protocol.name as protocol, \ 
    425425                        port_state.state, service_info.product, \ 
    426426                        service_info.version, service_info.extrainfo, \ 
     
    430430                        port_state.pk = ? AND service_info.pk = ? AND \ 
    431431                        service_name.pk = service_info.fk_service_name", 
    432                         (protocol_id, port_state_id, service_info_id)).fetchall()[0] 
     432                        (protocol_id, port_state_id,  
     433                         service_info_id)).fetchall()[0] 
    433434         
    434435        return fullpdata 
  • branch/ggpolo/umitDB/search.py

    r937 r949  
    149149            # search for port with number in looking_for 
    150150            if compare: 
    151                 #self.conn.create_function("compare", 3, perform_comparison) 
    152                 #search = self.cursor.execute("SELECT port.portid FROM port \ 
    153                 #               JOIN _host_port ON (_host_port.fk_port=port.pk) \ 
    154                 #               WHERE _host_port.fk_host=? AND \ 
    155                 #               compare(port.portid, ?, ?)", (host_id, 
    156                 #                                             compare,  
    157                 #                                             looking_for)).fetchall() 
    158151                search = self.cursor.execute("SELECT port.portid FROM port \ 
    159152                               JOIN _host_port ON (_host_port.fk_port=port.pk) \ 
  • branch/ggpolo/umitInventory/changeslist.py

    r935 r949  
    291291                if item[0] == host_scans[d][0]: 
    292292                    d += 1 
     293                else: 
     294                    down_order.append(item[0]) 
     295                    down_d[item[0]] = item[1] 
    293296         
    294297        return (down_d, down_order) 
  • branch/ggpolo/umitInventory/invtree.py

    r940 r949  
    3737class InventoryTree(gtk.HBox): 
    3838    """ 
    39     A hbox that holds a gtk.TreeView that holds all inventories in database. 
     39    A HBox that holds a Notebook that holds a ScrolledWindow that holds a  
     40    TreeView that holds all inventories in database. 
    4041    """ 
    4142     
  • branch/ggpolo/umitInventory/viewer.py

    r940 r949  
    6161    umitdb = Path.umitdb_ng 
    6262 
     63NI_VER = '0.2' 
    6364controller = Path.sched_control 
    6465inventory_info = _("Info") 
     
    836837        # check for database changes 
    837838        prev_stat = self.db_stat 
    838         possibly_new = os.stat(umitdb).st_mtime 
     839        try: 
     840            possibly_new = os.stat(umitdb).st_mtime 
     841        except OSError: 
     842            return True 
     843 
    839844        if prev_stat != possibly_new: 
    840845            #print "db changed" 
     
    844849        # check for changes in schemas 
    845850        prev_state = self.schema_stat 
    846         possibly_new = os.stat(Path.sched_schemas).st_mtime 
     851        try: 
     852            possibly_new = os.stat(Path.sched_schemas).st_mtime 
     853        except OSError: 
     854            return True 
     855 
    847856        if prev_state != possibly_new: 
    848857            #print "schemas changed" 
     
    857866        Set window properties. 
    858867        """ 
    859         self.set_title(_("UMIT Network Inventory 0.1.5")) 
     868        self.set_title(_("UMIT Network Inventory %s" % NI_VER)) 
    860869        # a size for testing 
    861870        self.set_position(gtk.WIN_POS_CENTER)