[test] Fix redirect problem for downloading test data on windows.

BUG=v8:4254
LOG=n
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
TBR=jkummerow@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#29510}
This commit is contained in:
machenbach 2015-07-07 03:35:27 -07:00 committed by Commit bot
parent a104e7c9b4
commit e7330a644f

View File

@ -32,6 +32,7 @@ from os.path import isdir
from os.path import join
import platform
import re
import subprocess
import urllib2
@ -121,5 +122,15 @@ def IsWindows():
def URLRetrieve(source, destination):
"""urllib is broken for SSL connections via a proxy therefore we
can't use urllib.urlretrieve()."""
if IsWindows():
try:
# In python 2.7.6 on windows, urlopen has a problem with redirects.
# Try using curl instead. Note, this is fixed in 2.7.8.
subprocess.check_call(["curl", source, '-L', '-o', destination])
return
except:
# If there's no curl, fall back to urlopen.
print "Curl is currently not installed. Falling back to python."
pass
with open(destination, 'w') as f:
f.write(urllib2.urlopen(source).read())