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

phillip.eby python-checkins at python.org
Thu Jul 20 22:41:02 CEST 2006


Author: phillip.eby
Date: Thu Jul 20 22:41:01 2006
New Revision: 50733

Modified:
   sandbox/branches/setuptools-0.6/EasyInstall.txt
   sandbox/branches/setuptools-0.6/setuptools/package_index.py
Log:
EasyInstall now includes setuptools version information in the
``User-Agent`` string sent to websites it visits. (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	Thu Jul 20 22:41:01 2006
@@ -1190,6 +1190,10 @@
 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
 

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	Thu Jul 20 22:41:01 2006
@@ -141,9 +141,9 @@
             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 @@
         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 @@
             else:
                 return filename
 
-
     def scan_url(self, url):
         self.process_url(url, True)
 


More information about the Python-checkins mailing list