Use curl as fallback for downloading Chromium

[email protected]

Change-Id: Id6a26dca86dd33a9029630c788e78ab7e3a49514
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2194869
Commit-Queue: Yang Guo <[email protected]>
Reviewed-by: Tim van der Lippe <[email protected]>
diff --git a/scripts/deps/download_chromium.py b/scripts/deps/download_chromium.py
index 506e1fe..983bca6 100755
--- a/scripts/deps/download_chromium.py
+++ b/scripts/deps/download_chromium.py
@@ -8,9 +8,11 @@
 """
 
 import argparse
+import io
 import os
 import shutil
 import stat
+import subprocess
 import sys
 import urllib
 import zipfile
@@ -52,7 +54,13 @@
         shutil.rmtree(options.target, ignore_errors=False, onerror=handleAccessDeniedOnWindows)
 
     # Download again and save build number
-    filehandle, headers = urllib.urlretrieve(options.url)
+    try:
+        filehandle, headers = urllib.urlretrieve(options.url)
+    except:
+        print("Using curl as fallback. You should probably update OpenSSL.")
+        filehandle = io.BytesIO(
+            subprocess.check_output(
+                ['curl', '--output', '-', '-sS', options.url]))
     zip_file = zipfile.ZipFile(filehandle, 'r')
     zip_file.extractall(path=options.target)
     # Fix permissions. Do this recursively is necessary for MacOS bundles.