From 04206434e7d146d49984115e7f46a810d5b1e527 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Fri, 3 Mar 2023 23:05:19 +0000 Subject: [PATCH] Improve .boto message visibility An out of date .boto file can prevent Google employees from being able to download the Chromium toolchain from Google storage. An error message was added to gsutil.py to help developers diagnose this, but the message was swallowed by get_toolchain_if_necessary.py. This change prints the error message, and adds '*' * 80 separators to make it more visible. An obsolete import is also removed. Bug: 1414152 Change-Id: I69d5a786672304ed363c291e0a8ef89f8be0f2e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4310059 Reviewed-by: Aravind Vasudevan Commit-Queue: Bruce Dawson --- gsutil.py | 5 ++++- win_toolchain/get_toolchain_if_necessary.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gsutil.py b/gsutil.py index 7642625b3..ffdf9cb9f 100755 --- a/gsutil.py +++ b/gsutil.py @@ -260,10 +260,13 @@ def run_gsutil(target, args, clean=False): # Notify user that their .boto file might be outdated. if b'Your credentials are invalid.' in p.stderr: + # Make sure this error message is visible when invoked by gclient runhooks + separator = '*' * 80 print( + '\n' + separator + '\n' + 'Warning: You might have an outdated .boto file. If this issue ' 'persists after running `gsutil.py config`, try removing your ' - '.boto file.', + '.boto file.\n' + separator + '\n', file=sys.stderr) _print_subprocess_result(p) diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index aa556cba4..6b25ad7e7 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -26,7 +26,6 @@ import hashlib import filecmp import json import os -import platform import shutil import subprocess import sys @@ -257,7 +256,11 @@ def CanAccessToolchainBucket(): """Checks whether the user has access to gs://chrome-wintoolchain/.""" gsutil = download_from_google_storage.Gsutil( download_from_google_storage.GSUTIL_DEFAULT_PATH, boto_path=None) - code, _, _ = gsutil.check_call('ls', 'gs://chrome-wintoolchain/') + code, stdout, stderr = gsutil.check_call('ls', 'gs://chrome-wintoolchain/') + if code != 0: + # Make sure any error messages are made visible to the user. + print(stderr, file=sys.stderr, end='') + print(stdout, end='') return code == 0