From 0ae5113b9bc5824a09b0e2c4e317084a4402cc0c Mon Sep 17 00:00:00 2001 From: tarek Date: Wed, 26 Aug 2009 08:42:44 +0200 Subject: fixed #16 and #18: BadStatusLine and ValueError in package_index.urlopen --HG-- branch : distribute extra : rebase_source : 6159cf23c0dc4effd40b525066266eefd292b96e --- setuptools/package_index.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'setuptools/package_index.py') 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 -- cgit v1.2.1