[Python-checkins] r52003 - in sandbox/trunk/setuptools: EasyInstall.txt setuptools/package_index.py
phillip.eby
python-checkins at python.org
Mon Sep 25 23:24:20 CEST 2006
Author: phillip.eby
Date: Mon Sep 25 23:24:19 2006
New Revision: 52003
Modified:
sandbox/trunk/setuptools/EasyInstall.txt
sandbox/trunk/setuptools/setuptools/package_index.py
Log:
Fix SF download problems when server returns HTML instead of a 404. Use
sf-mirrors.telecommunity.com as a fallback to get SF mirror info if the
first dl.sourceforge.net attempt doesn't work.
Modified: sandbox/trunk/setuptools/EasyInstall.txt
==============================================================================
--- sandbox/trunk/setuptools/EasyInstall.txt (original)
+++ sandbox/trunk/setuptools/EasyInstall.txt Mon Sep 25 23:24:19 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: sandbox/trunk/setuptools/setuptools/package_index.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/package_index.py (original)
+++ sandbox/trunk/setuptools/setuptools/package_index.py Mon Sep 25 23:24:19 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