| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 def check_bucket_permissions(base_url, gsutil): | 113 def check_bucket_permissions(base_url, gsutil): |
| 114 code, _, ls_err = gsutil.check_call('ls', base_url) | 114 code, _, ls_err = gsutil.check_call('ls', base_url) |
| 115 if code != 0: | 115 if code != 0: |
| 116 print >> sys.stderr, ls_err | 116 print >> sys.stderr, ls_err |
| 117 if code == 403: | 117 if code == 403: |
| 118 print >> sys.stderr, 'Got error 403 while authenticating to %s.' % base_url | 118 print >> sys.stderr, 'Got error 403 while authenticating to %s.' % base_url |
| 119 print >> sys.stderr, 'Try running "download_from_google_storage --config".' | 119 print >> sys.stderr, 'Try running "download_from_google_storage --config".' |
| 120 elif code == 404: | 120 elif code == 404: |
| 121 print >> sys.stderr, '%s not found.' % base_url | 121 print >> sys.stderr, '%s not found.' % base_url |
| 122 return (base_url, code) | 122 return code |
| 123 | 123 |
| 124 | 124 |
| 125 def check_platform(target): | 125 def check_platform(target): |
| 126 """Checks if any parent directory of target matches (win|mac|linux).""" | 126 """Checks if any parent directory of target matches (win|mac|linux).""" |
| 127 assert os.path.isabs(target) | 127 assert os.path.isabs(target) |
| 128 root, target_name = os.path.split(target) | 128 root, target_name = os.path.split(target) |
| 129 if not target_name: | 129 if not target_name: |
| 130 return None | 130 return None |
| 131 if target_name in ('linux', 'mac', 'win'): | 131 if target_name in ('linux', 'mac', 'win'): |
| 132 return target_name | 132 return target_name |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 return code | 460 return code |
| 461 | 461 |
| 462 return download_from_google_storage( | 462 return download_from_google_storage( |
| 463 input_filename, base_url, gsutil, options.num_threads, options.directory, | 463 input_filename, base_url, gsutil, options.num_threads, options.directory, |
| 464 options.recursive, options.force, options.output, options.ignore_errors, | 464 options.recursive, options.force, options.output, options.ignore_errors, |
| 465 options.sha1_file, options.verbose, options.auto_platform) | 465 options.sha1_file, options.verbose, options.auto_platform) |
| 466 | 466 |
| 467 | 467 |
| 468 if __name__ == '__main__': | 468 if __name__ == '__main__': |
| 469 sys.exit(main(sys.argv)) | 469 sys.exit(main(sys.argv)) |
| OLD | NEW |