Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 if status_code_match: | 98 if status_code_match: |
| 99 return (int(status_code_match.group(1)), out, err) | 99 return (int(status_code_match.group(1)), out, err) |
| 100 if ('You are attempting to access protected data with ' | 100 if ('You are attempting to access protected data with ' |
| 101 'no configured credentials.' in err): | 101 'no configured credentials.' in err): |
| 102 return (403, out, err) | 102 return (403, out, err) |
| 103 if 'No such object' in err: | 103 if 'No such object' in err: |
| 104 return (404, out, err) | 104 return (404, out, err) |
| 105 return (code, out, err) | 105 return (code, out, err) |
| 106 | 106 |
| 107 | 107 |
| 108 def check_bucket_permissions(base_url, gsutil): | 108 def check_bucket_permissions(base_url, gsutil): |
|
hinoka
2015/02/12 18:03:54
I'd actually be okay with removing this entirely.
| |
| 109 code, _, ls_err = gsutil.check_call('ls', base_url) | 109 code, _, ls_err = gsutil.check_call('ls', base_url + '/..') |
|
Michael Moss
2015/02/12 16:39:21
Based on your description of "only ls the bucket i
| |
| 110 if code != 0: | 110 if code != 0: |
| 111 print >> sys.stderr, ls_err | 111 print >> sys.stderr, ls_err |
| 112 if code == 403: | 112 if code == 403: |
| 113 print >> sys.stderr, 'Got error 403 while authenticating to %s.' % base_url | 113 print >> sys.stderr, 'Got error 403 while authenticating to %s.' % base_url |
| 114 print >> sys.stderr, 'Try running "download_from_google_storage --config".' | 114 print >> sys.stderr, 'Try running "download_from_google_storage --config".' |
| 115 elif code == 404: | 115 elif code == 404: |
| 116 print >> sys.stderr, '%s not found.' % base_url | 116 print >> sys.stderr, '%s not found.' % base_url |
| 117 return code | 117 return code |
| 118 | 118 |
| 119 | 119 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 return code | 461 return code |
| 462 | 462 |
| 463 return download_from_google_storage( | 463 return download_from_google_storage( |
| 464 input_filename, base_url, gsutil, options.num_threads, options.directory, | 464 input_filename, base_url, gsutil, options.num_threads, options.directory, |
| 465 options.recursive, options.force, options.output, options.ignore_errors, | 465 options.recursive, options.force, options.output, options.ignore_errors, |
| 466 options.sha1_file, options.verbose, options.auto_platform) | 466 options.sha1_file, options.verbose, options.auto_platform) |
| 467 | 467 |
| 468 | 468 |
| 469 if __name__ == '__main__': | 469 if __name__ == '__main__': |
| 470 sys.exit(main(sys.argv)) | 470 sys.exit(main(sys.argv)) |
| OLD | NEW |