aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/package_index.py
diff options
context:
space:
mode:
authortarek <none@none>2009-08-26 08:42:44 +0200
committertarek <none@none>2009-08-26 08:42:44 +0200
commit0ae5113b9bc5824a09b0e2c4e317084a4402cc0c (patch)
treece06a09a47cb8327c9d9fe6ca0567ce079d9bc56 /setuptools/package_index.py
parent6c31d16ce512c164e211aec0fa1d44437dfe5c61 (diff)
downloadexternal_python_setuptools-0ae5113b9bc5824a09b0e2c4e317084a4402cc0c.tar.gz
external_python_setuptools-0ae5113b9bc5824a09b0e2c4e317084a4402cc0c.tar.bz2
external_python_setuptools-0ae5113b9bc5824a09b0e2c4e317084a4402cc0c.zip
fixed #16 and #18: BadStatusLine and ValueError in package_index.urlopen
--HG-- branch : distribute extra : rebase_source : 6159cf23c0dc4effd40b525066266eefd292b96e
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-xsetuptools/package_index.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index e601cc15..fef62942 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -1,5 +1,6 @@
"""PyPI and direct package downloading"""
import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO
+import httplib
from pkg_resources import *
from distutils import log
from distutils.errors import DistutilsError
@@ -577,13 +578,27 @@ class PackageIndex(Environment):
return local_open(url)
try:
return open_with_auth(url)
+ except ValueError, v:
+ msg = ' '.join([str(arg) for arg in v.args])
+ if warning:
+ self.warn(warning, msg)
+ else:
+ raise DistutilsError('%s %s' % (url, msg))
except urllib2.HTTPError, v:
return v
except urllib2.URLError, v:
- if warning: self.warn(warning, v.reason)
+ if warning:
+ self.warn(warning, v.reason)
else:
raise DistutilsError("Download error for %s: %s"
% (url, v.reason))
+ except httplib.BadStatusLine, v:
+ if warning:
+ self.warn(warning, v.line)
+ else:
+ raise DistutilsError('%s returned a bad status line. '
+ 'The server might be down, %s' % \
+ (url, v.line))
def _download_url(self, scheme, url, tmpdir):
# Determine download filename