Commit cf09e206 authored by Guido A.J. Stevens's avatar Guido A.J. Stevens

Refs #257. Provide a pull request for patch provided in

https://github.com/buildout/buildout/issues/257#issuecomment-159423299
parent 144830d8
...@@ -31,17 +31,28 @@ try: ...@@ -31,17 +31,28 @@ try:
except ImportError: except ImportError:
# Python 2 # Python 2
import base64
from urlparse import urlparse from urlparse import urlparse
from urlparse import urlunparse
import urllib2 import urllib2
def urlretrieve(url, path): def urlretrieve(url, tmp):
"""Work around Python issue 24599 """Work around Python issue 24599 includig basic auth support
""" """
url_obj = urllib2.urlopen(url) scheme, netloc, path, params, query, frag = urlparse(url)
with open(path, 'wb') as fp: auth, host = urllib2.splituser(netloc)
if auth:
url = urlunparse((scheme, host, path, params, query, frag))
req = urllib2.Request(url)
base64string = base64.encodestring(auth)[:-1]
basic = "Basic " + base64string
req.add_header("Authorization", basic)
else:
req = urllib2.Request(url)
url_obj = urllib2.urlopen(req)
with open(tmp, 'wb') as fp:
fp.write(url_obj.read()) fp.write(url_obj.read())
return path, url_obj.info() return tmp, url_obj.info()
from zc.buildout.easy_install import realpath from zc.buildout.easy_install import realpath
......
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