Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: upload_to_google_storage.py

Issue 955993006: Handle KeyboardInterrupt consistently in python scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: tweek test expectations Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« clang_format.py ('K') | « tests/presubmit_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« clang_format.py ('K') | « tests/presubmit_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698