Use curl to download packages for webkitpy autoinstaller
authordean_johnson@apple.com <dean_johnson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Apr 2019 22:07:47 +0000 (22:07 +0000)
committerdean_johnson@apple.com <dean_johnson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Apr 2019 22:07:47 +0000 (22:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197164

Reviewed by Darin Adler.

* Scripts/webkitpy/common/system/autoinstall.py:
(AutoInstaller._download): Use curl(1) to download packages necessary for
webkitpy/thirdparty/autoinstalled since Python2's urllib2 module can result in unnecessary
errors which are not present when using curl(1).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244513 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/autoinstall.py

index 5412b67..40b1feb 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-22  Dean Johnson  <dean_johnson@apple.com>
+
+        Use curl to download packages for webkitpy autoinstaller
+        https://bugs.webkit.org/show_bug.cgi?id=197164
+
+        Reviewed by Darin Adler.
+
+        * Scripts/webkitpy/common/system/autoinstall.py:
+        (AutoInstaller._download): Use curl(1) to download packages necessary for
+        webkitpy/thirdparty/autoinstalled since Python2's urllib2 module can result in unnecessary
+        errors which are not present when using curl(1).
+
 2019-04-22  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, rolling out r244502.
index 5a9423b..3e6d88e 100644 (file)
@@ -46,6 +46,7 @@ import re
 from distutils import dir_util
 from glob import glob
 import urlparse
+import subprocess
 
 
 _log = logging.getLogger(__name__)
@@ -418,8 +419,18 @@ class AutoInstaller(object):
             return cache
 
         target_path = os.path.join(scratch_dir, target_filename)
-        with open(target_path, "wb") as stream:
-            self._download_to_stream(url, stream)
+
+        if os.name == 'posix':
+            try:
+                command = ['curl', url, '-L', '--output', target_path]
+                with open(os.devnull, 'w') as devnull:
+                    subprocess.check_call(command, stdout=devnull, stderr=devnull)
+            except subprocess.CalledProcessError as e:
+                _log.info('Error: Failed to download {} to {}. Command: {}'.format(url, target_path, command))
+                raise
+        else:  # Windows
+            with open(target_path, "wb") as stream:
+                self._download_to_stream(url, stream)
 
         if _CACHE_ENV_VAR in os.environ:
             dir_util.copy_tree(scratch_dir, os.environ[_CACHE_ENV_VAR])