Commit f4258162 authored by Reinout van Rees's avatar Reinout van Rees

Merge pull request #253 from stefano-m/allow_download_behind_proxy_fix_32

Enable downloading behind a proxy by using urllib2
parents eb0bc6bd 9de262f5
......@@ -22,17 +22,26 @@ try:
# Python 3
from urllib.request import FancyURLopener, URLopener, urlretrieve
from urllib.parse import urlparse
from urllib import request as urllib # for monkey patch below :(
from urllib import request
class PatchedURLopener(FancyURLopener):
http_error_default = URLopener.http_error_default
request._urlopener = PatchedURLopener() # Ook! Monkey patch!
except ImportError:
# Python 2
from urllib import FancyURLopener, URLopener, urlretrieve
from urlparse import urlparse
import urllib
class URLOpener(FancyURLopener):
http_error_default = URLopener.http_error_default
import urllib2
urllib._urlopener = URLOpener() # Ook! Monkey patch!
def urlretrieve(url, path):
"""Work around Python issue 24599
"""
url_obj = urllib2.urlopen(url)
with open(path, 'wb') as fp:
fp.write(url_obj.read())
return path, url_obj.info()
from zc.buildout.easy_install import realpath
......@@ -45,6 +54,7 @@ import sys
import tempfile
import zc.buildout
class ChecksumError(zc.buildout.UserError):
pass
......
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