Commit bad362fe authored by PJ Eby's avatar PJ Eby

EasyInstall now includes setuptools version information in the

``User-Agent`` string sent to websites it visits. (backport from trunk)

--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4050733
parent fa18a05d
...@@ -1190,6 +1190,10 @@ displayed MD5 info (broken onto two lines for readability):: ...@@ -1190,6 +1190,10 @@ displayed MD5 info (broken onto two lines for readability)::
Release Notes/Change History Release Notes/Change History
============================ ============================
0.6c1
* EasyInstall now includes setuptools version information in the
``User-Agent`` string sent to websites it visits.
0.6b4 0.6b4
* Fix creating Python wrappers for non-Python scripts * Fix creating Python wrappers for non-Python scripts
......
...@@ -141,9 +141,9 @@ def find_external_links(url, page): ...@@ -141,9 +141,9 @@ def find_external_links(url, page):
if match: if match:
yield urlparse.urljoin(url, match.group(1)) 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): ...@@ -617,13 +617,14 @@ class PackageIndex(Environment):
if url.startswith('file:'): if url.startswith('file:'):
return local_open(url) return local_open(url)
try: try:
return urllib2.urlopen(url) request = urllib2.Request(url)
request.add_header('User-Agent', user_agent)
return urllib2.urlopen(request)
except urllib2.HTTPError, v: except urllib2.HTTPError, v:
return v return v
except urllib2.URLError, v: except urllib2.URLError, v:
raise DistutilsError("Download error: %s" % v.reason) raise DistutilsError("Download error: %s" % v.reason)
def _download_url(self, scheme, url, tmpdir): def _download_url(self, scheme, url, tmpdir):
# Determine download filename # Determine download filename
# #
...@@ -653,7 +654,6 @@ class PackageIndex(Environment): ...@@ -653,7 +654,6 @@ class PackageIndex(Environment):
else: else:
return filename return filename
def scan_url(self, url): def scan_url(self, url):
self.process_url(url, True) self.process_url(url, True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment