diff options
-rwxr-xr-x | EasyInstall.txt | 4 | ||||
-rwxr-xr-x | setuptools/package_index.py | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt index 95bc016f..b3ac28bd 100755 --- a/EasyInstall.txt +++ b/EasyInstall.txt @@ -1190,6 +1190,10 @@ displayed MD5 info (broken onto two lines for readability):: Release Notes/Change History ============================ +0.6c1 + * EasyInstall now includes setuptools version information in the + ``User-Agent`` string sent to websites it visits. + 0.6b4 * Fix creating Python wrappers for non-Python scripts diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 525f0e73..5bccbb8e 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -141,9 +141,9 @@ def find_external_links(url, page): if match: yield urlparse.urljoin(url, match.group(1)) - - - +user_agent = "Python-urllib/%s setuptools/%s" % ( + urllib2.__version__, require('setuptools')[0].version +) @@ -617,13 +617,14 @@ class PackageIndex(Environment): if url.startswith('file:'): return local_open(url) try: - return urllib2.urlopen(url) + request = urllib2.Request(url) + request.add_header('User-Agent', user_agent) + return urllib2.urlopen(request) except urllib2.HTTPError, v: return v except urllib2.URLError, v: raise DistutilsError("Download error: %s" % v.reason) - def _download_url(self, scheme, url, tmpdir): # Determine download filename # @@ -653,7 +654,6 @@ class PackageIndex(Environment): else: return filename - def scan_url(self, url): self.process_url(url, True) |