| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 help='Use \\0 instead of \\n when parsing ' | 214 help='Use \\0 instead of \\n when parsing ' |
| 215 'the file list from stdin. This is useful if the input ' | 215 'the file list from stdin. This is useful if the input ' |
| 216 'is coming from "find ... -print0".') | 216 'is coming from "find ... -print0".') |
| 217 (options, args) = parser.parse_args() | 217 (options, args) = parser.parse_args() |
| 218 | 218 |
| 219 # Enumerate our inputs. | 219 # Enumerate our inputs. |
| 220 input_filenames = get_targets(args, parser, options.use_null_terminator) | 220 input_filenames = get_targets(args, parser, options.use_null_terminator) |
| 221 | 221 |
| 222 # Make sure we can find a working instance of gsutil. | 222 # Make sure we can find a working instance of gsutil. |
| 223 if os.path.exists(GSUTIL_DEFAULT_PATH): | 223 if os.path.exists(GSUTIL_DEFAULT_PATH): |
| 224 gsutil = Gsutil(GSUTIL_DEFAULT_PATH) | 224 gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto) |
| 225 else: | 225 else: |
| 226 gsutil = None | 226 gsutil = None |
| 227 for path in os.environ["PATH"].split(os.pathsep): | 227 for path in os.environ["PATH"].split(os.pathsep): |
| 228 if os.path.exists(path) and 'gsutil' in os.listdir(path): | 228 if os.path.exists(path) and 'gsutil' in os.listdir(path): |
| 229 gsutil = Gsutil(os.path.join(path, 'gsutil')) | 229 gsutil = Gsutil(os.path.join(path, 'gsutil'), boto_path=options.boto) |
| 230 if not gsutil: | 230 if not gsutil: |
| 231 parser.error('gsutil not found in %s, bad depot_tools checkout?' % | 231 parser.error('gsutil not found in %s, bad depot_tools checkout?' % |
| 232 GSUTIL_DEFAULT_PATH) | 232 GSUTIL_DEFAULT_PATH) |
| 233 | 233 |
| 234 # Check we have a valid bucket with valid permissions. | 234 # Check we have a valid bucket with valid permissions. |
| 235 base_url, code = check_bucket_permissions(options.bucket, gsutil) | 235 base_url, code = check_bucket_permissions(options.bucket, gsutil) |
| 236 if code: | 236 if code: |
| 237 return code | 237 return code |
| 238 | 238 |
| 239 return upload_to_google_storage( | 239 return upload_to_google_storage( |
| 240 input_filenames, base_url, gsutil, options.force, options.use_md5, | 240 input_filenames, base_url, gsutil, options.force, options.use_md5, |
| 241 options.num_threads, options.skip_hashing) | 241 options.num_threads, options.skip_hashing) |
| 242 | 242 |
| 243 | 243 |
| 244 if __name__ == '__main__': | 244 if __name__ == '__main__': |
| 245 sys.exit(main(sys.argv)) | 245 sys.exit(main(sys.argv)) |
| OLD | NEW |