Changeset 11020:ecf11f8d4342 in orange for Orange/utils/addons.py


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

Show progress during reloading of add-ons list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/utils/addons.py

    r11018 r11020  
    8181    return result 
    8282 
    83 def refresh_available_addons(force=False): 
     83def refresh_available_addons(force=False, progress_callback=None): 
    8484    pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi') 
     85    if progress_callback: 
     86        progress_callback(1, 0) 
    8587 
    8688    pkg_dict = {} 
     
    98100 
    99101    docs = {} 
    100     for name, (_, version) in pkg_dict.items(): 
     102    if progress_callback: 
     103        progress_callback(len(pkg_dict)+1, 1) 
     104    for i, (name, (_, version)) in enumerate(pkg_dict.items()): 
    101105        if force or name not in addons or addons[name].available_version != version: 
    102106            try: 
     
    126130                traceback.print_exc() 
    127131                warnings.warn('Could not load data for the following add-on: %s'%name) 
     132        if progress_callback: 
     133            progress_callback(len(pkg_dict)+1, i+2) 
    128134 
    129135    rebuild_index() 
Note: See TracChangeset for help on using the changeset viewer.