[Python-checkins] r52004 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/package_index.py

phillip.eby python-checkins at python.org
Mon Sep 25 23:32:00 CEST 2006


Author: phillip.eby
Date: Mon Sep 25 23:31:59 2006
New Revision: 52004
Modified:
 sandbox/branches/setuptools-0.6/EasyInstall.txt
 sandbox/branches/setuptools-0.6/setuptools/package_index.py
Log:
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)
Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt
==============================================================================
--- sandbox/branches/setuptools-0.6/EasyInstall.txt	(original)
+++ sandbox/branches/setuptools-0.6/EasyInstall.txt	Mon Sep 25 23:31:59 2006
@@ -355,6 +355,14 @@
 ``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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1198,6 +1206,10 @@
 * 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.
 
Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/package_index.py	(original)
+++ sandbox/branches/setuptools-0.6/setuptools/package_index.py	Mon Sep 25 23:31:59 2006
@@ -533,7 +533,6 @@
 
 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
@@ -572,9 +571,18 @@
 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:
@@ -588,7 +596,9 @@
 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()
@@ -603,16 +613,6 @@
 
 
 
-
-
-
-
-
-
-
-
-
-
 def open_url(self, url):
 if url.startswith('file:'):
 return local_open(url)
@@ -648,16 +648,16 @@
 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():
@@ -700,7 +700,8 @@
 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']
@@ -734,5 +735,4 @@
 
 
 
-
 # this line is a kludge to keep the trailing blank lines for pje's editor


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /