Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2227)

Unified Diff: download_from_google_storage.py

Issue 76583002: Add no_auth flag to skip auth checking for buckets that don't require it. Also fix tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Set the boto file to empty if --no_auth is specified Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/download_from_google_storage_unittests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: download_from_google_storage.py
diff --git a/download_from_google_storage.py b/download_from_google_storage.py
index bbb9e64f3b08865eac683a374e5a2006be7a636e..e00ac626218be3efd1c1014a1760b6d0879a6f3a 100755
--- a/download_from_google_storage.py
+++ b/download_from_google_storage.py
@@ -45,8 +45,12 @@ class Gsutil(object):
def get_sub_env(self):
env = os.environ.copy()
- if self.boto_path:
+ if self.boto_path == os.devnull:
+ env['AWS_CREDENTIAL_FILE'] = ''
+ env['BOTO_CONFIG'] = ''
+ elif self.boto_path:
env['AWS_CREDENTIAL_FILE'] = self.boto_path
+ env['BOTO_CONFIG'] = self.boto_path
else:
custompath = env.get('AWS_CREDENTIAL_FILE', '~/.boto') + '.depot_tools'
custompath = os.path.expanduser(custompath)
@@ -297,7 +301,10 @@ def main(args):
help='Alias for "gsutil config". Run this if you want '
'to initialize your saved Google Storage '
'credentials.')
- parser.add_option('-p', '--platform',
+ parser.add_option('-n', '--no_auth', action='store_true',
+ help='Skip auth checking. Use if it\'s known that the '
+ 'target bucket is a public bucket.')
+ parser.add_option('-p', '--platform',
help='A regular expression that is compared against '
'Python\'s sys.platform. If this option is specified, '
'the download will happen only if there is a match.')
@@ -311,6 +318,10 @@ def main(args):
options.platform)
return 0
+ # Set the boto file to /dev/null if we don't need auth.
+ if options.no_auth:
+ options.boto = os.devnull
+
# Make sure we can find a working instance of gsutil.
if os.path.exists(GSUTIL_DEFAULT_PATH):
gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto)
« no previous file with comments | « no previous file | tests/download_from_google_storage_unittests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698