Skip reauthentication when ~/.boto file is present

This fix skips luci-auth ~/.boto file is already present.

Bug: 1407306, 1359383
Change-Id: I333b6baf693bfed295a2467c7a543432111be4dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4175408
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
diff --git a/gsutil.py b/gsutil.py
index 9363d64..5d93783 100755
--- a/gsutil.py
+++ b/gsutil.py
@@ -222,6 +222,11 @@
   return subprocess.run(cmd, **kwargs)
 
 
+def is_boto_present():
+  """Returns true if the .boto file is present in the default path."""
+  return os.path.isfile(os.path.join(os.path.expanduser('~'), '.boto'))
+
+
 def run_gsutil(target, args, clean=False):
   # Redirect gsutil config calls to luci-auth.
   if os.getenv(GSUTIL_ENABLE_LUCI_AUTH) == '1' and 'config' in args:
@@ -259,7 +264,7 @@
   # Bypass luci-auth when run within a bot or .boto file is set.
   if (os.getenv(GSUTIL_ENABLE_LUCI_AUTH) != '1' or _is_luci_context()
       or os.getenv('SWARMING_HEADLESS') == '1' or os.getenv('BOTO_CONFIG')
-      or os.getenv('AWS_CREDENTIAL_FILE')):
+      or os.getenv('AWS_CREDENTIAL_FILE') or is_boto_present()):
     return _run_subprocess(cmd, interactive=True).returncode
 
   return luci_context(cmd).returncode