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 """Download files from Google Storage based on SHA1 sums.""" | 6 """Download files from Google Storage based on SHA1 sums.""" |
7 | 7 |
8 | 8 |
9 import hashlib | 9 import hashlib |
10 import optparse | 10 import optparse |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 help='Number of downloader threads to run.') | 318 help='Number of downloader threads to run.') |
319 parser.add_option('-d', '--directory', action='store_true', | 319 parser.add_option('-d', '--directory', action='store_true', |
320 help='The target is a directory. ' | 320 help='The target is a directory. ' |
321 'Cannot be used with -s/--sha1_file.') | 321 'Cannot be used with -s/--sha1_file.') |
322 parser.add_option('-s', '--sha1_file', action='store_true', | 322 parser.add_option('-s', '--sha1_file', action='store_true', |
323 help='The target is a file containing a sha1 sum. ' | 323 help='The target is a file containing a sha1 sum. ' |
324 'Cannot be used with -d/--directory.') | 324 'Cannot be used with -d/--directory.') |
325 parser.add_option('-g', '--config', action='store_true', | 325 parser.add_option('-g', '--config', action='store_true', |
326 help='Alias for "gsutil config". Run this if you want ' | 326 help='Alias for "gsutil config". Run this if you want ' |
327 'to initialize your saved Google Storage ' | 327 'to initialize your saved Google Storage ' |
328 'credentials.') | 328 'credentials. This will create a read-only ' |
329 'credentials file in ~/.boto.depot_tools.') | |
329 parser.add_option('-n', '--no_auth', action='store_true', | 330 parser.add_option('-n', '--no_auth', action='store_true', |
330 help='Skip auth checking. Use if it\'s known that the ' | 331 help='Skip auth checking. Use if it\'s known that the ' |
331 'target bucket is a public bucket.') | 332 'target bucket is a public bucket.') |
332 parser.add_option('-p', '--platform', | 333 parser.add_option('-p', '--platform', |
333 help='A regular expression that is compared against ' | 334 help='A regular expression that is compared against ' |
334 'Python\'s sys.platform. If this option is specified, ' | 335 'Python\'s sys.platform. If this option is specified, ' |
335 'the download will happen only if there is a match.') | 336 'the download will happen only if there is a match.') |
336 parser.add_option('-v', '--verbose', action='store_true', | 337 parser.add_option('-v', '--verbose', action='store_true', |
337 help='Output extra diagnostic and progress information.') | 338 help='Output extra diagnostic and progress information.') |
338 | 339 |
(...skipping 15 matching lines...) Expand all Loading... | |
354 if os.path.exists(GSUTIL_DEFAULT_PATH): | 355 if os.path.exists(GSUTIL_DEFAULT_PATH): |
355 gsutil = Gsutil(GSUTIL_DEFAULT_PATH, | 356 gsutil = Gsutil(GSUTIL_DEFAULT_PATH, |
356 boto_path=options.boto, | 357 boto_path=options.boto, |
357 bypass_prodaccess=options.no_auth) | 358 bypass_prodaccess=options.no_auth) |
358 else: | 359 else: |
359 parser.error('gsutil not found in %s, bad depot_tools checkout?' % | 360 parser.error('gsutil not found in %s, bad depot_tools checkout?' % |
360 GSUTIL_DEFAULT_PATH) | 361 GSUTIL_DEFAULT_PATH) |
361 | 362 |
362 # Passing in -g/--config will run our copy of GSUtil, then quit. | 363 # Passing in -g/--config will run our copy of GSUtil, then quit. |
363 if options.config: | 364 if options.config: |
364 return gsutil.call('config') | 365 return gsutil.call('config', '-r', '-o', |
366 os.path.expanduser('~/.boto.depot_tools')) | |
M-A Ruel
2014/01/10 23:32:00
Note that we've seen '~' expansion issues on Windo
Ryan Tseng
2014/01/10 23:34:21
Didn't know that. Line 64/65 would also need to b
| |
365 | 367 |
366 if not args: | 368 if not args: |
367 parser.error('Missing target.') | 369 parser.error('Missing target.') |
368 if len(args) > 1: | 370 if len(args) > 1: |
369 parser.error('Too many targets.') | 371 parser.error('Too many targets.') |
370 if not options.bucket: | 372 if not options.bucket: |
371 parser.error('Missing bucket. Specify bucket with --bucket.') | 373 parser.error('Missing bucket. Specify bucket with --bucket.') |
372 if options.sha1_file and options.directory: | 374 if options.sha1_file and options.directory: |
373 parser.error('Both --directory and --sha1_file are specified, ' | 375 parser.error('Both --directory and --sha1_file are specified, ' |
374 'can only specify one.') | 376 'can only specify one.') |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 return code | 408 return code |
407 | 409 |
408 return download_from_google_storage( | 410 return download_from_google_storage( |
409 input_filename, base_url, gsutil, options.num_threads, options.directory, | 411 input_filename, base_url, gsutil, options.num_threads, options.directory, |
410 options.recursive, options.force, options.output, options.ignore_errors, | 412 options.recursive, options.force, options.output, options.ignore_errors, |
411 options.sha1_file, options.verbose) | 413 options.sha1_file, options.verbose) |
412 | 414 |
413 | 415 |
414 if __name__ == '__main__': | 416 if __name__ == '__main__': |
415 sys.exit(main(sys.argv)) | 417 sys.exit(main(sys.argv)) |
OLD | NEW |