aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/package_index.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2006-01-23 16:29:16 +0000
committerPJ Eby <distutils-sig@python.org>2006-01-23 16:29:16 +0000
commitf6235b239c8327962c0025ec607541a6648d53a8 (patch)
treecf5a6965a094fecb4f358d7a4ef5c40519e41a69 /setuptools/package_index.py
parenta16d5ce9244243a530433434ce155d87506f3b3f (diff)
downloadexternal_python_setuptools-f6235b239c8327962c0025ec607541a6648d53a8.tar.gz
external_python_setuptools-f6235b239c8327962c0025ec607541a6648d53a8.tar.bz2
external_python_setuptools-f6235b239c8327962c0025ec607541a6648d53a8.zip
Randomly select a SourceForge mirror IP for each download, to work
around too-aggressive DNS caches on some platforms, that could otherwise result in a stuck bad IP. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042156
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-xsetuptools/package_index.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index c48968f1..2813631e 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -1,6 +1,6 @@
"""PyPI and direct package downloading"""
-import sys, os.path, re, urlparse, urllib2, shutil
+import sys, os.path, re, urlparse, urllib2, shutil, random, socket
from pkg_resources import *
from distutils import log
from distutils.errors import DistutilsError
@@ -562,18 +562,28 @@ class PackageIndex(Environment):
log.warn(msg, *args)
+
+
+
+
+
+
+
+
+
+
def fix_sf_url(url):
scheme, server, path, param, query, frag = urlparse.urlparse(url)
if server!='prdownloads.sourceforge.net':
return url
return urlparse.urlunparse(
- (scheme, 'dl.sourceforge.net', 'sourceforge'+path, param, '', frag)
+ (scheme, get_sf_ip(), 'sourceforge'+path, param, '', frag)
)
-
-
-
-
+def get_sf_ip(_mirrors=[]):
+ if not _mirrors:
+ _mirrors[:] = socket.gethostbyname_ex('dl.sourceforge.net')[-1]
+ return random.choice(_mirrors)