Changeset 11021:258cd74e0722 in orange for Orange/utils/addons.py


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

Show progress during installation of add-ons.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/utils/addons.py

    r11020 r11021  
    196196 
    197197 
    198 def install(name): 
     198def install(name, progress_callback=None): 
     199    if progress_callback: 
     200        progress_callback(1, 0) 
    199201    import site 
    200202    try: 
    201203        import urllib 
    202         egg = urllib.urlretrieve(addons[name].release_url)[0] 
     204        rh = (lambda done, bs, fs: progress_callback(fs/bs, done)) if progress_callback else None 
     205        egg = urllib.urlretrieve(addons[name].release_url, reporthook=rh)[0] 
    203206    except Exception, e: 
    204207        raise Exception("Unable to download add-on from repository: %s" % e) 
     
    237240        func() 
    238241 
    239 def uninstall(name): #TODO 
     242def uninstall(name, progress_callback=None): #TODO 
    240243    raise Exception('Unable to uninstall %s: uninstallation of add-ons is not yet implemented.') 
    241244    # Implement this either by using pip.commands.uninstall, and complain if pip is not installed on the system, 
    242245    # or by "stealing" pip's uninstallation code. 
    243246 
    244 def upgrade(name): 
    245     install(name) 
     247def upgrade(name, progress_callback=None): 
     248    install(name, progress_callback) 
    246249 
    247250load_installed_addons() 
Note: See TracChangeset for help on using the changeset viewer.