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

Side by Side Diff: download_from_google_storage.py

Issue 16072023: Change download_from_google_storage.py to not run gsutil config when receiving a 403 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Download files from Google Storage based on SHA1 sums.""" 6 """Download files from Google Storage based on SHA1 sums."""
7 7
8 8
9 import hashlib 9 import hashlib
10 import optparse 10 import optparse
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 75
76 def check_bucket_permissions(bucket, gsutil): 76 def check_bucket_permissions(bucket, gsutil):
77 if not bucket: 77 if not bucket:
78 print >> sys.stderr, 'Missing bucket %s.' 78 print >> sys.stderr, 'Missing bucket %s.'
79 return (None, 1) 79 return (None, 1)
80 base_url = 'gs://%s' % bucket 80 base_url = 'gs://%s' % bucket
81 81
82 code, _, ls_err = gsutil.check_call('ls', base_url) 82 code, _, ls_err = gsutil.check_call('ls', base_url)
83 if code == 403: 83 if code == 403:
84 code, _, _ = gsutil.call('config') 84 print >> sys.stderr, 'Got error 403 while authenticating to %s.' % base_url
85 if code != 0: 85 print >> sys.stderr, 'Try running "gsutil config".'
86 print >> sys.stderr, 'Error while authenticating to %s.' % base_url
87 elif code == 404: 86 elif code == 404:
88 print >> sys.stderr, '%s not found.' % base_url 87 print >> sys.stderr, '%s not found.' % base_url
89 elif code != 0: 88 elif code != 0:
90 print >> sys.stderr, ls_err 89 print >> sys.stderr, ls_err
91 return (base_url, code) 90 return (base_url, code)
92 91
93 92
94 def get_sha1(filename): 93 def get_sha1(filename):
95 sha1 = hashlib.sha1() 94 sha1 = hashlib.sha1()
96 with open(filename, 'rb') as f: 95 with open(filename, 'rb') as f:
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return code 329 return code
331 330
332 return download_from_google_storage( 331 return download_from_google_storage(
333 input_filename, base_url, gsutil, options.num_threads, options.directory, 332 input_filename, base_url, gsutil, options.num_threads, options.directory,
334 options.recursive, options.force, options.output, options.ignore_errors, 333 options.recursive, options.force, options.output, options.ignore_errors,
335 options.sha1_file) 334 options.sha1_file)
336 335
337 336
338 if __name__ == '__main__': 337 if __name__ == '__main__':
339 sys.exit(main(sys.argv)) 338 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | tests/download_from_google_storage_unittests.py » ('j') | tests/download_from_google_storage_unittests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698