Revert "Warn users when .boto might be outdated"
This reverts commit e2f35370f5a84676be3d3ff25426992820a22978.
Reason for revert: Potentially breaks https://source.chromium.org/chromium/chromium/src/+/main:build/fuchsia/gcs_download.py;l=34
Original change's description:
> Warn users when .boto might be outdated
>
> Fixed: 1414152
> Change-Id: I887de64a72777c92413ee921099dd762361f6c5c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4251897
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
> Reviewed-by: Traian Captan <tcaptan@chromium.org>
Change-Id: Idd403b3054643b437ee165b8af2e775dc7e1abb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4262468
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
diff --git a/gsutil.py b/gsutil.py
index 042e4da..8b1e523 100755
--- a/gsutil.py
+++ b/gsutil.py
@@ -147,9 +147,6 @@
def _is_luci_context():
"""Returns True if the script is run within luci-context"""
- if os.getenv('SWARMING_HEADLESS') == '1':
- return True
-
luci_context_env = os.getenv('LUCI_CONTEXT')
if not luci_context_env:
return False
@@ -170,7 +167,12 @@
if b'Not logged in.' in p.stderr:
return _run_subprocess(cmd, interactive=True)
- _print_subprocess_result(p)
+ if p.stdout:
+ print(p.stdout.decode('utf-8'), end='')
+
+ if p.stderr:
+ print(p.stderr.decode('utf-8'), file=sys.stderr, end='')
+
return p
@@ -203,20 +205,9 @@
return subprocess.run(cmd, **kwargs)
-def _print_subprocess_result(p):
- """Prints the subprocess result to stdout & stderr."""
- if p.stdout:
- print(p.stdout.decode('utf-8'), end='')
-
- if p.stderr:
- print(p.stderr.decode('utf-8'), file=sys.stderr, end='')
-
-
def is_boto_present():
"""Returns true if the .boto file is present in the default path."""
- return os.getenv('BOTO_CONFIG') or os.getenv(
- 'AWS_CREDENTIAL_FILE') or os.path.isfile(
- os.path.join(os.path.expanduser('~'), '.boto'))
+ return os.path.isfile(os.path.join(os.path.expanduser('~'), '.boto'))
def run_gsutil(target, args, clean=False):
@@ -253,27 +244,12 @@
gsutil_bin
] + args_opt + args
- # When .boto is present, try without additional wrappers and handle specific
- # errors.
- if is_boto_present():
- p = _run_subprocess(cmd)
-
- # Notify user that their .boto file might be outdated.
- if b'Your credentials are invalid.' in p.stderr:
- print(
- 'Warning: You might have an outdated .boto file. If this issue '
- 'persists after running `gsutil.py config`, try removing your '
- '.boto file.',
- file=sys.stderr)
-
- _print_subprocess_result(p)
- return p.returncode
-
- # Skip wrapping commands if luci-auth is already being
- if _is_luci_context():
+ # Bypass luci-auth when run within a bot or .boto file is set.
+ if (_is_luci_context() or os.getenv('SWARMING_HEADLESS') == '1'
+ or os.getenv('BOTO_CONFIG') or os.getenv('AWS_CREDENTIAL_FILE')
+ or is_boto_present()):
return _run_subprocess(cmd, interactive=True).returncode
- # Wrap gsutil with luci-auth context.
return luci_context(cmd).returncode