| 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 |
| 11 import Queue | 11 import Queue |
| 12 import re | 12 import re |
| 13 import stat | 13 import stat |
| 14 import sys | 14 import sys |
| 15 import threading | 15 import threading |
| 16 import time | 16 import time |
| 17 | 17 |
| 18 from download_from_google_storage import check_bucket_permissions | |
| 19 from download_from_google_storage import get_sha1 | 18 from download_from_google_storage import get_sha1 |
| 20 from download_from_google_storage import Gsutil | 19 from download_from_google_storage import Gsutil |
| 21 from download_from_google_storage import printer_worker | 20 from download_from_google_storage import printer_worker |
| 22 from download_from_google_storage import GSUTIL_DEFAULT_PATH | 21 from download_from_google_storage import GSUTIL_DEFAULT_PATH |
| 23 | 22 |
| 24 USAGE_STRING = """%prog [options] target [target2 ...]. | 23 USAGE_STRING = """%prog [options] target [target2 ...]. |
| 25 Target is the file intended to be uploaded to Google Storage. | 24 Target is the file intended to be uploaded to Google Storage. |
| 26 If target is "-", then a list of files will be taken from standard input | 25 If target is "-", then a list of files will be taken from standard input |
| 27 | 26 |
| 28 This script will generate a file (original filename).sha1 containing the | 27 This script will generate a file (original filename).sha1 containing the |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 gsutil = None | 235 gsutil = None |
| 237 for path in os.environ["PATH"].split(os.pathsep): | 236 for path in os.environ["PATH"].split(os.pathsep): |
| 238 if os.path.exists(path) and 'gsutil' in os.listdir(path): | 237 if os.path.exists(path) and 'gsutil' in os.listdir(path): |
| 239 gsutil = Gsutil(os.path.join(path, 'gsutil'), boto_path=options.boto) | 238 gsutil = Gsutil(os.path.join(path, 'gsutil'), boto_path=options.boto) |
| 240 if not gsutil: | 239 if not gsutil: |
| 241 parser.error('gsutil not found in %s, bad depot_tools checkout?' % | 240 parser.error('gsutil not found in %s, bad depot_tools checkout?' % |
| 242 GSUTIL_DEFAULT_PATH) | 241 GSUTIL_DEFAULT_PATH) |
| 243 | 242 |
| 244 base_url = 'gs://%s' % options.bucket | 243 base_url = 'gs://%s' % options.bucket |
| 245 | 244 |
| 246 # Check we have a valid bucket with valid permissions. | |
| 247 code = check_bucket_permissions(base_url, gsutil) | |
| 248 if code: | |
| 249 return code | |
| 250 | |
| 251 return upload_to_google_storage( | 245 return upload_to_google_storage( |
| 252 input_filenames, base_url, gsutil, options.force, options.use_md5, | 246 input_filenames, base_url, gsutil, options.force, options.use_md5, |
| 253 options.num_threads, options.skip_hashing) | 247 options.num_threads, options.skip_hashing) |
| 254 | 248 |
| 255 | 249 |
| 256 if __name__ == '__main__': | 250 if __name__ == '__main__': |
| 257 sys.exit(main(sys.argv)) | 251 sys.exit(main(sys.argv)) |
| OLD | NEW |