HaikuPorts
  • Login
  • Preferences
  • Help/Guide
  • Wiki
  • Timeline
  • Roadmap
  • View Tickets
  • Search
  • Port Log
  • Blog

Context Navigation

  • Back to Ticket #249

Ticket #249: without_connection_patch_2.diff

File without_connection_patch_2.diff, 2.1 KB (added by haikubot, 6 years ago)

new one

  • haikuporter

     
    409409                self.lastTime = time.time() 
    410410                os.chdir(self.downloadDir) 
    411411                for src_uri in self.bepKeys['SRC_URI']: 
    412                         print "Fetching " + src_uri 
    413                         try: 
    414                                 file_uri = urllib2.urlopen(src_uri) 
    415                                 headers = file_uri.info() 
    416                                 remote_size = long(headers.getheader("Content-Length")) 
    417                                 src_uri = file_uri.geturl() 
     412                        fp = self.downloadDir+'/'+src_uri[src_uri.rindex('/') + 1:] 
     413                        if os.path.isfile(fp): 
     414                                print 'Seems file already exist, checkout: ' + fp + '.\nSkip fetching file...' 
    418415                                self.src_local = src_uri[src_uri.rindex('/') + 1:] 
    419                                 if os.path.exists(self.src_local): 
    420                                         local_size = os.stat(self.src_local).st_size 
    421                                 else: 
    422                                         local_size = 0 
    423                                 # check if file was already downloaded 
    424                                 if local_size == remote_size: 
    425                                         print '  file was already downloaded... continuing' 
    426                                 else: 
    427                                         urllib.urlretrieve(src_uri, self.src_local, self.downloadProgressIndicator) 
    428                                         print '' 
    429                                 # succesfully downloaded source archive 
    430416                                return 
    431                         except: 
    432                                 raise 
    433                                 print "  error... trying next location" 
    434                                 continue 
     417                        else: 
     418                                print "Fetching " + src_uri 
     419                                try: 
     420                                        file_uri = urllib2.urlopen(src_uri) 
     421                                        headers = file_uri.info() 
     422                                        remote_size = long(headers.getheader("Content-Length")) 
     423                                        src_uri = file_uri.geturl() 
     424                                        self.src_local = src_uri[src_uri.rindex('/') + 1:] 
     425                                        if os.path.exists(self.src_local): 
     426                                                local_size = os.stat(self.src_local).st_size 
     427                                        else: 
     428                                                local_size = 0 
     429                                        # check if file was already downloaded 
     430                                        if local_size == remote_size: 
     431                                                print '  file was already downloaded... continuing' 
     432                                        else: 
     433                                                urllib.urlretrieve(src_uri, self.src_local, self.downloadProgressIndicator) 
     434                                                print '' 
     435                                        # succesfully downloaded source archive 
     436                                        return 
     437                                except: 
     438                                        raise 
     439                                        print "  error... trying next location" 
     440                                        continue 
    435441                # failed to fetch source 
    436442                print "Failed to fetch source package from all locations" 
    437443                sys.exit() 

Download in other formats:

  • Original Format

Trac Powered

Powered by Trac 0.13dev-r10686
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/