| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Downloads a single file from a Google Storage Bucket. | |
| 7 | |
| 8 To test: | |
| 9 cd .../buildbot/slave/skia_slave_scripts/utils | |
| 10 CR_BUILDBOT_PATH=../../../third_party/chromium_buildbot | |
| 11 PYTHONPATH=$CR_BUILDBOT_PATH/scripts:$CR_BUILDBOT_PATH/site_config \ | |
| 12 python download_from_bucket.py \ | |
| 13 --source_gsurl=gs://chromium-skia-gm/DEPS --dest=~/DEPS | |
| 14 """ | |
| 15 | |
| 16 import optparse | |
| 17 import sys | |
| 18 | |
| 19 from slave import slave_utils | |
| 20 | |
| 21 | |
| 22 def DownloadFromBucket(source_gsurl, dest): | |
| 23 status = slave_utils.GSUtilDownloadFile(source_gsurl, dest) | |
| 24 if status != 0: | |
| 25 raise Exception('ERROR: GSUtilDownloadFile error %d. "%s" -> "%s"' % ( | |
| 26 status, source_gsurl, dest)) | |
| 27 return 0 | |
| 28 | |
| 29 | |
| 30 def main(argv): | |
| 31 option_parser = optparse.OptionParser() | |
| 32 option_parser.add_option( | |
| 33 '', '--source_gsurl', | |
| 34 help='gs://url of the file to download') | |
| 35 option_parser.add_option( | |
| 36 '', '--dest', | |
| 37 help='Destination file/directory where the file will be downloaded.') | |
| 38 (options, _args) = option_parser.parse_args() | |
| 39 return DownloadFromBucket(source_gsurl=options.source_gsurl, | |
| 40 dest=options.dest) | |
| 41 | |
| 42 | |
| 43 if '__main__' == __name__: | |
| 44 sys.exit(main(None)) | |
| OLD | NEW |