Changeset 1295

Show
Ignore:
Timestamp:
08/09/07 01:54:48 (6 years ago)
Author:
ggpolo
Message:

Added modules for handling data removal, and some minor changes

Location:
branch/ggpolo
Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/higwidgets/higlabels.py

    r1179 r1295  
    2626""" 
    2727 
    28 __all__ = ['HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel', 'HIGDialogLabel'] 
     28__all__ = ['HIGSectionLabel', 'HIGHintSectionLabel', 'HIGEntryLabel',  
     29           'HIGDialogLabel'] 
    2930 
    3031import gtk 
     
    4445class HIGHintSectionLabel(gtk.HBox, object): 
    4546    """ 
    46     Bold label used to define sections, with a little icon that shows up a hint when mouse is 
    47     over it. 
     47    Bold label used to define sections, with a little icon that shows up a  
     48    hint when mouse is over it. 
    4849    """ 
    4950    def __init__(self, text=None, hint=None): 
     
    6263 
    6364        self.hint_image = gtk.Image() 
    64         self.hint_image.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_SMALL_TOOLBAR) 
     65        self.hint_image.set_from_stock(gtk.STOCK_DIALOG_INFO,  
     66                                       gtk.ICON_SIZE_SMALL_TOOLBAR) 
    6567 
    6668        self.add(self.hint_image) 
  • branch/ggpolo/share/umit/config/umit.conf

    r1258 r1295  
    9595search_db = 1 
    9696 
     97[database] 
     98umit_decay = 60 
     99inventory_decay = 0 
  • branch/ggpolo/umitDB/Remove.py

    r1292 r1295  
    1919 
    2020from datetime import datetime, timedelta 
     21 
     22from umitCore.Logging import log 
    2123 
    2224from umitDB.Connection import ConnectDB 
     
    8890        to_remove = scans_ids.difference(inventory_scans_ids) 
    8991         
     92        if not to_remove: 
     93            # nothing to do 
     94            return 
     95 
     96        log.debug(">>> Removing UMIT scans older than %d days \ 
     97from database.." % older_than) 
     98 
    9099        # remove scans 
    91100        for scan_id in to_remove: 
    92101            self.remove_scan(scan_id) 
     102             
     103        log.debug(">>> Removal completed") 
    93104         
    94105         
     
    110121                                        (old_data_date, )).fetchall() 
    111122        scans_ids = [id[0] for id in scans_ids] 
     123 
     124        if not scans_ids: 
     125            # nothing to do 
     126            return 
     127 
     128        log.debug(">>> Removing Inventory scans older than %d days \ 
     129from database.." % older_than) 
    112130         
    113131        # remove scans 
     
    125143             
    126144        self.conn.commit() 
     145         
     146        log.debug(">>> Removal completed") 
    127147             
    128148             
  • branch/ggpolo/umitDB/XMLStore.py

    r1178 r1295  
    1919 
    2020from datetime import datetime 
     21 
    2122from umitCore.NmapParser import NmapParser 
     23 
    2224from umitDB.Connection import ConnectDB 
    2325from umitDB.Store import RawStore 
  • branch/ggpolo/umitGUI/MainWindow.py

    r1268 r1295  
    5555from umitCore.UmitDB import Scans, UmitDB 
    5656from umitCore.Utils import amiroot, is_maemo 
     57from umitCore.DataDecay import remove_old_data 
    5758import umitCore.Scheduler as Scheduler 
    5859 
     
    10181019            UmitDB().cleanup(SearchConfig().converted_save_time) 
    10191020             
    1020             # Stop Scheduler if it is running 
    1021             #if os.path.isfile(os.path.split(Path.config_file)[0] + \ 
    1022             #"/schedrunning"): 
    1023             #    subprocess.Popen([sys.executable, Path.sched_control, 'stop']) 
     1021            # Remove old data from database 
     1022            remove_old_data() 
    10241023 
    10251024            gtk.main_quit() 
  • branch/ggpolo/umitInventory/Viewer.py

    r1261 r1295  
    3434from umitCore.I18N import _ 
    3535from umitCore.Paths import Path 
     36from umitCore.DataDecay import remove_old_data 
    3637 
    3738from umitDB.Retrieve import InventoryRetrieve 
     
    4647from umitInventory.InventoryTree import InventoryTree 
    4748from umitInventory.Timeline import TLHolder 
     49from umitInventory.ConfigureDataRemoval import ConfigureDataRemoval 
    4850 
    4951umitdb = Path.umitdb_ng 
     
    375377        # hosts info 
    376378        hb = gtk.HBox() 
    377         hb.pack_start(gtk.Label(_("Hosts: %s" % ', '.join(host for host in hosts))), False, False, 0) 
     379        hb.pack_start(gtk.Label(_("Hosts: %s" % ', '.join(host for host in hosts))),  
     380                      False, False, 0) 
    378381        box.pack_start(hb, False, False, 0) 
    379382         
     
    419422        for invid, invname in self.invdb.get_inventories_ids_names(): 
    420423            root = tr.append(None, ['%s' % invname]) 
    421             tr.append(root, [inventory_info]) 
    422424             
    423425            # retrieve scans id for each inventory 
    424             for scan in self.invdb.get_scans_id_for_inventory(invid): 
     426            scans_ids = self.invdb.get_scans_id_for_inventory(invid) 
     427            if scans_ids: 
     428                tr.append(root, [inventory_info]) 
     429             
     430            for scan in scans_ids: 
    425431 
    426432                # retrieve scan finish timestamp 
     
    436442                    # check if host is already in current Inventory 
    437443                    new_host = False                     
    438                     #if self.addresses.has_key(invname): 
     444                     
    439445                    if invname in self.addresses: 
    440446                        if not addr in self.addresses[invname]: 
    441                             newlist = self.addresses[invname] # this is the old  
    442                                                               # list actually 
    443                             newlist.append(addr) # now this is the new list 
    444                             self.addresses[invname] = newlist 
     447                            self.addresses[invname].append(addr) 
    445448                            new_host = True 
    446449                    else: 
     
    663666             None, self.schedctrl.status_text, 
    664667             self.schedctrl._scheduler_control), 
     668             
     669            # Edit 
     670            ('Control Data Removal', None, _("Data Removal"), None, 
     671             _("Data Removal"), self._edit_data_removal) 
    665672        ] 
    666673         
     
    711718                    </menu> 
    712719                    <menuitem action='ShowTips' /> 
     720                    <menuitem action='Control Data Removal' /> 
    713721                </menu> 
    714722            </menubar> 
     
    733741 
    734742         
     743    def _edit_data_removal(self, event): 
     744        """ 
     745        Open window for editing data removal for Inventories. 
     746        """ 
     747        w = ConfigureDataRemoval() 
     748        w.show_all() 
     749         
     750         
    735751    def _edit_inventory(self, event): 
    736752        """ 
     
    763779            self.daddy.running_ni = False 
    764780        else: # started umit with -i argument 
     781            # Remove old data from database 
     782            remove_old_data() 
     783             
    765784            gtk.main_quit() 
    766785