[test] Fix redirect problem for downloading test data on windows.
authormachenbach <machenbach@chromium.org>
Tue, 7 Jul 2015 10:35:27 +0000 (03:35 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 7 Jul 2015 10:35:33 +0000 (10:35 +0000)
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}

tools/testrunner/local/utils.py

index 13bd280..2842b13 100644 (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())