Stop using urllib.urlretrieve() directly.

Using urllib for SSL connections when behind a proxy is known to be
broken, so apply the same fix from depot_tools r149742 and use a wrapper
around urllib2 instead.

R=jkummerow@chromium.org
TEST=run test262 behind corporate proxy

Review URL: https://codereview.chromium.org/297663003

Patch from Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21402 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 58661c15
...@@ -31,9 +31,9 @@ import os ...@@ -31,9 +31,9 @@ import os
import shutil import shutil
import sys import sys
import tarfile import tarfile
import urllib
from testrunner.local import testsuite from testrunner.local import testsuite
from testrunner.local import utils
from testrunner.objects import testcase from testrunner.objects import testcase
...@@ -102,7 +102,7 @@ class PromiseAplusTestSuite(testsuite.TestSuite): ...@@ -102,7 +102,7 @@ class PromiseAplusTestSuite(testsuite.TestSuite):
directory = os.path.join(self.root, TEST_NAME) directory = os.path.join(self.root, TEST_NAME)
if not os.path.exists(archive): if not os.path.exists(archive):
print('Downloading {0} from {1} ...'.format(TEST_NAME, TEST_URL)) print('Downloading {0} from {1} ...'.format(TEST_NAME, TEST_URL))
urllib.urlretrieve(TEST_URL, archive) utils.URLRetrieve(TEST_URL, archive)
if os.path.exists(directory): if os.path.exists(directory):
shutil.rmtree(directory) shutil.rmtree(directory)
...@@ -129,7 +129,7 @@ class PromiseAplusTestSuite(testsuite.TestSuite): ...@@ -129,7 +129,7 @@ class PromiseAplusTestSuite(testsuite.TestSuite):
os.mkdir(directory) os.mkdir(directory)
path = os.path.join(directory, SINON_FILENAME) path = os.path.join(directory, SINON_FILENAME)
if not os.path.exists(path): if not os.path.exists(path):
urllib.urlretrieve(SINON_URL, path) utils.URLRetrieve(SINON_URL, path)
hash = hashlib.sha256() hash = hashlib.sha256()
with open(path, 'rb') as f: with open(path, 'rb') as f:
for chunk in iter(lambda: f.read(8192), ''): for chunk in iter(lambda: f.read(8192), ''):
......
...@@ -31,9 +31,9 @@ import os ...@@ -31,9 +31,9 @@ import os
import shutil import shutil
import sys import sys
import tarfile import tarfile
import urllib
from testrunner.local import testsuite from testrunner.local import testsuite
from testrunner.local import utils
from testrunner.objects import testcase from testrunner.objects import testcase
...@@ -97,7 +97,7 @@ class Test262TestSuite(testsuite.TestSuite): ...@@ -97,7 +97,7 @@ class Test262TestSuite(testsuite.TestSuite):
directory_old_name = os.path.join(self.root, "data.old") directory_old_name = os.path.join(self.root, "data.old")
if not os.path.exists(archive_name): if not os.path.exists(archive_name):
print "Downloading test data from %s ..." % archive_url print "Downloading test data from %s ..." % archive_url
urllib.urlretrieve(archive_url, archive_name) utils.URLRetrieve(archive_url, archive_name)
if os.path.exists(directory_name): if os.path.exists(directory_name):
if os.path.exists(directory_old_name): if os.path.exists(directory_old_name):
shutil.rmtree(directory_old_name) shutil.rmtree(directory_old_name)
......
...@@ -32,6 +32,7 @@ from os.path import isdir ...@@ -32,6 +32,7 @@ from os.path import isdir
from os.path import join from os.path import join
import platform import platform
import re import re
import urllib2
def GetSuitePaths(test_root): def GetSuitePaths(test_root):
...@@ -113,3 +114,10 @@ def GuessWordsize(): ...@@ -113,3 +114,10 @@ def GuessWordsize():
def IsWindows(): def IsWindows():
return GuessOS() == 'windows' return GuessOS() == 'windows'
def URLRetrieve(source, destination):
"""urllib is broken for SSL connections via a proxy therefore we
can't use urllib.urlretrieve()."""
with open(destination, 'w') as f:
f.write(urllib2.urlopen(source).read())
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