Changeset 11024:e7cba04312ff in orange for Orange/utils/addons.py


Ignore:
Timestamp:
11/14/12 13:29:21 (17 months ago)
Author:
Matija Polajnar <matija.polajnar@…>
Branch:
default
Message:

Add-ons: more robust handling of the add-ons database.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/utils/addons.py

    r11022 r11024  
    4848AOLIST_FILE = os.path.join(Orange.utils.environ.orange_settings_dir, "addons.shelve") 
    4949try: 
    50     addons = shelve.open(AOLIST_FILE) 
     50    addons = shelve.open(AOLIST_FILE, 'c') 
    5151    list(addons.items())  # Try to read the whole list. 
    5252except: 
     53    if os.path.isfile(AOLIST_FILE): 
     54        os.remove(AOLIST_FILE) 
    5355    addons = shelve.open(AOLIST_FILE, 'n') 
     56 
     57addons_corrupted = len(addons)==0 
    5458 
    5559addon_refresh_callback = [] 
     
    132136        if progress_callback: 
    133137            progress_callback(len(pkg_dict)+1, i+2) 
     138    addons_corrupted = False 
     139    addons.sync() 
    134140 
    135141    rebuild_index() 
     
    161167    for name in set(addons).difference(found): 
    162168        addons[name] = addons[name]._replace(installed_version = None) 
     169    addons.sync() 
    163170    rebuild_index() 
    164171 
Note: See TracChangeset for help on using the changeset viewer.