| 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 """Uploads files to Google Storage content addressed.""" | 6 """Uploads files to Google Storage content addressed.""" |
| 7 | 7 |
| 8 import hashlib | 8 import hashlib |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 help='Use \\0 instead of \\n when parsing ' | 227 help='Use \\0 instead of \\n when parsing ' |
| 228 'the file list from stdin. This is useful if the input ' | 228 'the file list from stdin. This is useful if the input ' |
| 229 'is coming from "find ... -print0".') | 229 'is coming from "find ... -print0".') |
| 230 (options, args) = parser.parse_args() | 230 (options, args) = parser.parse_args() |
| 231 | 231 |
| 232 # Enumerate our inputs. | 232 # Enumerate our inputs. |
| 233 input_filenames = get_targets(args, parser, options.use_null_terminator) | 233 input_filenames = get_targets(args, parser, options.use_null_terminator) |
| 234 | 234 |
| 235 # Make sure we can find a working instance of gsutil. | 235 # Make sure we can find a working instance of gsutil. |
| 236 if os.path.exists(GSUTIL_DEFAULT_PATH): | 236 if os.path.exists(GSUTIL_DEFAULT_PATH): |
| 237 gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto) | 237 gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto, |
| 238 bypass_prodaccess=True) |
| 238 else: | 239 else: |
| 239 gsutil = None | 240 gsutil = None |
| 240 for path in os.environ["PATH"].split(os.pathsep): | 241 for path in os.environ["PATH"].split(os.pathsep): |
| 241 if os.path.exists(path) and 'gsutil' in os.listdir(path): | 242 if os.path.exists(path) and 'gsutil' in os.listdir(path): |
| 242 gsutil = Gsutil(os.path.join(path, 'gsutil'), boto_path=options.boto) | 243 gsutil = Gsutil(os.path.join(path, 'gsutil'), boto_path=options.boto) |
| 243 if not gsutil: | 244 if not gsutil: |
| 244 parser.error('gsutil not found in %s, bad depot_tools checkout?' % | 245 parser.error('gsutil not found in %s, bad depot_tools checkout?' % |
| 245 GSUTIL_DEFAULT_PATH) | 246 GSUTIL_DEFAULT_PATH) |
| 246 | 247 |
| 247 # Check we have a valid bucket with valid permissions. | 248 # Check we have a valid bucket with valid permissions. |
| 248 base_url, code = check_bucket_permissions(options.bucket, gsutil) | 249 base_url, code = check_bucket_permissions(options.bucket, gsutil) |
| 249 if code: | 250 if code: |
| 250 return code | 251 return code |
| 251 | 252 |
| 252 return upload_to_google_storage( | 253 return upload_to_google_storage( |
| 253 input_filenames, base_url, gsutil, options.force, options.use_md5, | 254 input_filenames, base_url, gsutil, options.force, options.use_md5, |
| 254 options.num_threads, options.skip_hashing) | 255 options.num_threads, options.skip_hashing) |
| 255 | 256 |
| 256 | 257 |
| 257 if __name__ == '__main__': | 258 if __name__ == '__main__': |
| 258 sys.exit(main(sys.argv)) | 259 sys.exit(main(sys.argv)) |
| OLD | NEW |