From 1adc91f99fe0aa7675dac6a44f2f320be3ea036f Mon Sep 17 00:00:00 2001 From: Robert Iannucci Date: Wed, 3 Jan 2018 22:49:29 -0800 Subject: [PATCH] [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/849663 Reviewed-by: Ryan Tseng Commit-Queue: Robbie Iannucci --- download_from_google_storage.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index 4db7c1c7be..c6ed7faa2b 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -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 + `/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()