Commits

Anonymous committed 15733d2

Fixed SF downloads aborting when a SF mirror returns an HTML page when it
should've returned a 404. Fall back to ``sf-mirrors.telecommunity.com``
round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work.
(backport from trunk)

  • Participants
  • Parent commits 7bf9f47
  • Branches setuptools-0.6

Comments (0)

Files changed (2)

File EasyInstall.txt

 ``python.org`` and ``myintranet.example.com`` domains, unless overridden on the
 command line.
 
+Note that if you want to allow downloads from Sourceforge, you need to enable
+the ``dl.sourceforge.net`` host.  All Sourceforge mirror downloads are treated
+as if they had this hostname.  (If a download attempt from
+``dl.sourceforge.net`` fails, it is automatically retried using a randomly
+selected mirror IP drawn from the ``sf-mirrors.telecommunity.com`` round-robin
+addres.  The IP's, however, are not checked against the ``--allow-hosts``
+mask.)
+
 
 Installing on Un-networked Machines
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  * Fixed not recogninzing ``win32.exe`` installers that included a custom
    bitmap.
 
+ * Fixed SF downloads aborting when a SF mirror returns an HTML page when it
+   should've returned a 404.  Fall back to ``sf-mirrors.telecommunity.com``
+   round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work.
+
 0.6c3
  * You once again use "python -m easy_install" with Python 2.4 and above.
 

File setuptools/package_index.py

 
     dl_blocksize = 8192
     def _download_to(self, url, filename):
-        self.url_ok(url,True)   # raises error if not allowed
         self.info("Downloading %s", url)
         # Download the file
         fp, tfp, info = None, None, None
     def reporthook(self, url, filename, blocknum, blksize, size):
         pass    # no-op
 
-    def retry_sf_download(self, url, filename):
+
+    def _attempt_download(self, url, filename):
+        headers = self._download_to(url, filename)
+        if 'html' in headers['content-type'].lower():
+            return self._download_html(url, headers, filename)
+        else:
+            return filename
+
+    def _retry_sf_download(self, url, filename):
+        self.url_ok(url, True)   # raises error if not allowed
         try:
-            return self._download_to(url, filename)
+            return self._attempt_download(url, filename)
         except (KeyboardInterrupt,SystemExit):
             raise
         except:
             self.warn("Download failed: %s", sys.exc_info()[1])
             url = urlparse.urlunparse((scheme, mirror, path, param, '', frag))
             try:
-                return self._download_to(url, filename)
+                return self._attempt_download(url, filename)
+            except (KeyboardInterrupt,SystemExit):
+                raise
             except:
                 _sf_mirrors.remove(mirror)  # don't retry the same mirror
                 mirror = get_sf_ip()
 
 
 
-
-
-
-
-
-
-
-
-
-
     def open_url(self, url):
         if url.startswith('file:'):
             return local_open(url)
         elif scheme=='file':
             return urllib2.url2pathname(urlparse.urlparse(url)[2])
         else:
-            headers = self.retry_sf_download(url, filename)
-            if 'html' in headers['content-type'].lower():
-                return self._download_html(url, headers, filename, tmpdir)
-            else:
-                return filename
+            return self._retry_sf_download(url, filename)
+
+
+
+
 
     def scan_url(self, url):
         self.process_url(url, True)
 
-    def _download_html(self, url, headers, filename, tmpdir):
+    def _download_html(self, url, headers, filename):
         file = open(filename)
         for line in file:
             if line.strip():
 def get_sf_ip():
     if not _sf_mirrors:
         try:
-            _sf_mirrors[:] = socket.gethostbyname_ex('dl.sourceforge.net')[-1]
+            _sf_mirrors[:] = socket.gethostbyname_ex(
+                'sf-mirrors.telecommunity.com')[-1]
         except socket.error:
             # DNS-bl0ck1n9 f1r3w4llz sUx0rs!
             _sf_mirrors[:] = ['dl.sourceforge.net']
 
 
 
-
 # this line is a kludge to keep the trailing blank lines for pje's editor