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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 max_ret_code = max(ret_code, max_ret_code) | 196 max_ret_code = max(ret_code, max_ret_code) |
197 if message: | 197 if message: |
198 print >> sys.stderr, message | 198 print >> sys.stderr, message |
199 | 199 |
200 if not max_ret_code: | 200 if not max_ret_code: |
201 print 'Success!' | 201 print 'Success!' |
202 | 202 |
203 return max_ret_code | 203 return max_ret_code |
204 | 204 |
205 | 205 |
206 def main(args): | 206 def main(): |
207 parser = optparse.OptionParser(USAGE_STRING) | 207 parser = optparse.OptionParser(USAGE_STRING) |
208 parser.add_option('-b', '--bucket', | 208 parser.add_option('-b', '--bucket', |
209 help='Google Storage bucket to upload to.') | 209 help='Google Storage bucket to upload to.') |
210 parser.add_option('-e', '--boto', help='Specify a custom boto file.') | 210 parser.add_option('-e', '--boto', help='Specify a custom boto file.') |
211 parser.add_option('-f', '--force', action='store_true', | 211 parser.add_option('-f', '--force', action='store_true', |
212 help='Force upload even if remote file exists.') | 212 help='Force upload even if remote file exists.') |
213 parser.add_option('-g', '--gsutil_path', default=GSUTIL_DEFAULT_PATH, | 213 parser.add_option('-g', '--gsutil_path', default=GSUTIL_DEFAULT_PATH, |
214 help='Path to the gsutil script.') | 214 help='Path to the gsutil script.') |
215 parser.add_option('-m', '--use_md5', action='store_true', | 215 parser.add_option('-m', '--use_md5', action='store_true', |
216 help='Generate MD5 files when scanning, and don\'t check ' | 216 help='Generate MD5 files when scanning, and don\'t check ' |
(...skipping 24 matching lines...) Expand all Loading... |
241 GSUTIL_DEFAULT_PATH) | 241 GSUTIL_DEFAULT_PATH) |
242 | 242 |
243 base_url = 'gs://%s' % options.bucket | 243 base_url = 'gs://%s' % options.bucket |
244 | 244 |
245 return upload_to_google_storage( | 245 return upload_to_google_storage( |
246 input_filenames, base_url, gsutil, options.force, options.use_md5, | 246 input_filenames, base_url, gsutil, options.force, options.use_md5, |
247 options.num_threads, options.skip_hashing) | 247 options.num_threads, options.skip_hashing) |
248 | 248 |
249 | 249 |
250 if __name__ == '__main__': | 250 if __name__ == '__main__': |
251 sys.exit(main(sys.argv)) | 251 try: |
| 252 sys.exit(main()) |
| 253 except KeyboardInterrupt: |
| 254 sys.stderr.write('interrupted\n') |
| 255 sys.exit(1) |
OLD | NEW |