Changeset 1522

Show
Ignore:
Timestamp:
10/20/08 11:37:07 (3 months ago)
Author:
astormont
Message:

Better exception handling for failed downloads

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wine-doors/trunk/src/application.py

    r1516 r1522  
    264264         
    265265        # Invoke the download helper 
    266         Download ( remote_file, self.cache_file, True, notify_type, notify_data ) 
     266        dl = Download ( remote_file, self.cache_file, True, notify_type, notify_data ) 
    267267        self.cache_file = self.cache_file.replace( ".gz", "" ) 
     268        return dl.status 
    268269 
    269270    def Extract ( self ): 
     
    306307             
    307308            # Run our handy little tools on our pack file 
    308             self.Download( self.pack_file, APP_PACK ) 
     309            if self.Download( self.pack_file, APP_PACK ) == DOWNLOAD_FAILED: 
     310                return 
    309311            self.Extract() 
    310312            self.Parse() 
     
    314316                (url, md5) = item 
    315317                log.Debug("* Retrieving installation resource to cache: " + url) 
    316                 self.Download( url, RESOURCE ) 
     318                if self.Download( url, RESOURCE ) == DOWNLOAD_FAILED: 
     319                    self.status = FILE_NOT_FOUND 
     320                    return 
    317321                if md5: 
    318322                    if md5file(self.cache_file) != md5: 
     
    447451        # In other words, add stuff usually added by self.InstallApplication 
    448452        if self.app_pack == {}: 
    449             self.Download( self.pack_file, APP_PACK ) 
     453            if self.Download( self.pack_file, APP_PACK ) == DOWNLOAD_FAILED: 
     454                return 
    450455            self.Extract() 
    451456            self.Parse() 
     
    533538        """ 
    534539        log.Debug("Uninstalling application: " + str(self.pack) + " " + str(self.version)) 
    535         self.Download( self.pack_file, APP_PACK ) 
     540        if self.Download( self.pack_file, APP_PACK ) == DOWNLOAD_FAILED: 
     541            return 
    536542        self.Extract() 
    537543        self.Parse() 
  • wine-doors/trunk/src/const.py

    r1480 r1522  
    2222ALL = -1 
    2323 
     24# Errors 
    2425FILE_NOT_FOUND = -3 
    2526 
     27# Download status 
     28( DOWNLOAD_NOTREADY, DOWNLOAD_FAILED, DOWNLOAD_OK ) = range( 3 ) 
     29 
    2630( REPO_NAME, REPO_URI ) = range( 2 ) 
    27 ( PACK_TILE, PACK_SHORTNAME, PACK_VERSION ) = range ( 3 ) 
     31( PACK_TILE, PACK_SHORTNAME, PACK_VERSION ) = range( 3 ) 
    2832 
    2933# Allow either or for filtering, this allows us to add an advanced search facility later 
  • wine-doors/trunk/src/utils.py

    r1480 r1522  
    124124    uitype = None 
    125125    def __init__( self, remote_uri, local_uri, cache=False, uitype=None, widget=None ): 
     126        self.status = DOWNLOAD_NOTREADY 
    126127        self.widget = widget 
    127128        self.cache = cache 
     
    161162            except: 
    162163                pass 
    163             urllib.urlretrieve( remote_uri, self.local_uri, self.UpdateProgress ) 
     164            try: 
     165                urllib.urlretrieve( remote_uri, self.local_uri, self.UpdateProgress ) 
     166            except IOError: 
     167                log.Error( "Unable to download file: " + remote_uri ) 
     168                self.status = DOWNLOAD_FAILED 
     169                return 
    164170            #self.wn_downloader['wn_downloader'].hide() 
    165171        self.Complete() 
     172        self.status = DOWNLOAD_OK 
    166173           
    167174    def UpdateProgress( self, blocks, block_size, total_size ):