Commit 1adc91f9 authored by Robert Iannucci's avatar Robert Iannucci Committed by Commit Bot

[download_from_google_storage] Use vpython to invoke gsutil.py.

This will allow all uses of this class to correctly move into
gsutil's personal vpython environment. In particular, the
get_toolchain_if_necessary script is pretty sneaky, and adds
depot_tools to sys.path to import and use this class.  This
means that if get_toolchain_if_necessary is invoked in a vanilla
vpython environment (or an environment otherwise incompatible with
gsutil.py), it's use of this class will fail.

R=hinoka@chromium.org, tandrii@chromium.org

Bug: 795146
Change-Id: I87309a8b878b465cda7f53db0a41f2f9e6da6f50
Reviewed-on: https://chromium-review.googlesource.com/849663Reviewed-by: 's avatarRyan Tseng <hinoka@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
parent edac7184
......@@ -54,11 +54,16 @@ def GetNormalizedPlatform():
# Common utilities
class Gsutil(object):
"""Call gsutil with some predefined settings. This is a convenience object,
and is also immutable."""
and is also immutable.
HACK: This object is used directly by the external script
`<depot_tools>/win_toolchain/get_toolchain_if_necessary.py`
"""
MAX_TRIES = 5
RETRY_BASE_DELAY = 5.0
RETRY_DELAY_MULTIPLE = 1.3
VPYTHON = 'vpython.bat' if GetNormalizedPlatform() == 'win32' else 'vpython'
def __init__(self, path, boto_path=None, timeout=None, version='4.28'):
if not os.path.exists(path):
......@@ -80,12 +85,12 @@ class Gsutil(object):
return env
def call(self, *args):
cmd = [sys.executable, self.path, '--force-version', self.version]
cmd = [self.VPYTHON, self.path, '--force-version', self.version]
cmd.extend(args)
return subprocess2.call(cmd, env=self.get_sub_env(), timeout=self.timeout)
def check_call(self, *args):
cmd = [sys.executable, self.path, '--force-version', self.version]
cmd = [self.VPYTHON, self.path, '--force-version', self.version]
cmd.extend(args)
((out, err), code) = subprocess2.communicate(
cmd,
......@@ -215,7 +220,7 @@ def _validate_tar_file(tar, prefix):
return all(map(_validate, tar.getmembers()))
def _downloader_worker_thread(thread_num, q, force, base_url,
gsutil, out_q, ret_codes, verbose, extract,
gsutil, out_q, ret_codes, _verbose, extract,
delete=True):
while True:
input_sha1_sum, output_filename = q.get()
......
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