Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is | 7 # Gets or updates a DumpRenderTree (a nearly headless build of chrome). This is |
| 8 # used for running browser tests of client applications. | 8 # used for running browser tests of client applications. |
| 9 | 9 |
| 10 import json | 10 import json |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 result, out = gsutil('ls', permanent_prefix % {'osname' : osname, | 154 result, out = gsutil('ls', permanent_prefix % {'osname' : osname, |
| 155 'num1': '*', 'num2': revision_num }) | 155 'num1': '*', 'num2': revision_num }) |
| 156 if result == 0: | 156 if result == 0: |
| 157 # First try to find one with the the second number the same as the | 157 # First try to find one with the the second number the same as the |
| 158 # requested number. | 158 # requested number. |
| 159 latest = out.split()[0] | 159 latest = out.split()[0] |
| 160 foundURL = True | 160 foundURL = True |
| 161 else: | 161 else: |
| 162 # Now try to find one with a nearby CL num. | 162 # Now try to find one with a nearby CL num. |
| 163 revision_num = int(revision_num) - 1 | 163 revision_num = int(revision_num) - 1 |
| 164 if revision_num <= 0: | |
| 165 too_early_error() | |
| 164 return latest | 166 return latest |
| 165 | 167 |
| 166 get_from_gsutil(name, directory, version_file, latest_pattern, osdict, | 168 get_from_gsutil(name, directory, version_file, latest_pattern, osdict, |
| 167 find_permanent_url, revision_num) | 169 find_permanent_url, revision_num) |
| 168 | 170 |
| 169 def get_sdk_revision(name, directory, version_file, latest_pattern, | 171 def get_sdk_revision(name, directory, version_file, latest_pattern, |
| 170 permanent_prefix, revision_num): | 172 permanent_prefix, revision_num): |
| 171 """Get a revision of the SDK from the editor build archive. | 173 """Get a revision of the SDK from the editor build archive. |
| 172 | 174 |
| 173 Args: | 175 Args: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 shutil.rmtree(temp_dir) | 281 shutil.rmtree(temp_dir) |
| 280 | 282 |
| 281 # create the version stamp | 283 # create the version stamp |
| 282 v = open(version_file, 'w') | 284 v = open(version_file, 'w') |
| 283 v.write(latest) | 285 v.write(latest) |
| 284 v.close() | 286 v.close() |
| 285 | 287 |
| 286 print 'Successfully downloaded to %s' % directory | 288 print 'Successfully downloaded to %s' % directory |
| 287 return 0 | 289 return 0 |
| 288 | 290 |
| 291 def too_early_error(): | |
| 292 """Quick shortcutting function, to return early if someone requests a revision | |
| 293 that is smaller than the earliest stored. This saves us from doing repeated | |
| 294 requests until we get down to 0.""" | |
| 295 print ('Unable to download requested revision because it is earlier than the ' | |
| 296 'earliest revision stored.') | |
| 297 sys.exit(1) | |
| 289 | 298 |
| 290 def main(): | 299 def main(): |
| 291 parser = optparse.OptionParser(usage='usage: %prog [options] download_name') | 300 parser = optparse.OptionParser(usage='usage: %prog [options] download_name') |
| 292 parser.add_option('-r', '--revision', dest='revision', | 301 parser.add_option('-r', '--revision', dest='revision', |
| 293 help='Desired revision number to retrieve for the SDK. If ' | 302 help='Desired revision number to retrieve for the SDK. If ' |
| 294 'unspecified, retrieve the latest SDK build.', | 303 'unspecified, retrieve the latest SDK build.', |
| 295 action='store', default=None) | 304 action='store', default=None) |
| 296 args, positional = parser.parse_args() | 305 args, positional = parser.parse_args() |
| 297 | 306 |
| 298 if positional[0] == 'dartium': | 307 if positional[0] == 'dartium': |
| 308 if args.revision < 4285: | |
|
Emily Fortuna
2012/08/17 19:52:02
I'm not a fan of hard-coding the "earliest revisio
| |
| 309 return too_early_error() | |
| 299 get_dartium_revision('Dartium', DARTIUM_DIR, DARTIUM_VERSION, | 310 get_dartium_revision('Dartium', DARTIUM_DIR, DARTIUM_VERSION, |
| 300 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PATTERN, | 311 DARTIUM_LATEST_PATTERN, DARTIUM_PERMANENT_PATTERN, |
| 301 args.revision) | 312 args.revision) |
| 302 elif positional[0] == 'chromedriver': | 313 elif positional[0] == 'chromedriver': |
| 314 if args.revision < 7823: | |
| 315 return too_early_error() | |
| 303 get_dartium_revision('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION, | 316 get_dartium_revision('chromedriver', CHROMEDRIVER_DIR, CHROMEDRIVER_VERSION, |
| 304 CHROMEDRIVER_LATEST_PATTERN, | 317 CHROMEDRIVER_LATEST_PATTERN, |
| 305 CHROMEDRIVER_PERMANENT_PATTERN, args.revision) | 318 CHROMEDRIVER_PERMANENT_PATTERN, args.revision) |
| 306 elif positional[0] == 'sdk': | 319 elif positional[0] == 'sdk': |
| 320 if args.revision < 9761: | |
| 321 return too_early_error() | |
| 307 get_sdk_revision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN, | 322 get_sdk_revision('sdk', SDK_DIR, SDK_VERSION, SDK_LATEST_PATTERN, |
| 308 SDK_PERMANENT, args.revision) | 323 SDK_PERMANENT, args.revision) |
| 309 elif positional[0] == 'drt': | 324 elif positional[0] == 'drt': |
| 325 if args.revision < 5342: | |
| 326 return too_early_error() | |
| 310 get_dartium_revision('DumpRenderTree', DRT_DIR, DRT_VERSION, | 327 get_dartium_revision('DumpRenderTree', DRT_DIR, DRT_VERSION, |
| 311 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN, | 328 DRT_LATEST_PATTERN, DRT_PERMANENT_PATTERN, |
| 312 args.revision) | 329 args.revision) |
| 313 else: | 330 else: |
| 314 print ('Please specify the target you wish to download from Google Storage ' | 331 print ('Please specify the target you wish to download from Google Storage ' |
| 315 '("drt", "dartium", "chromedriver", or "sdk")') | 332 '("drt", "dartium", "chromedriver", or "sdk")') |
| 316 | 333 |
| 317 if __name__ == '__main__': | 334 if __name__ == '__main__': |
| 318 sys.exit(main()) | 335 sys.exit(main()) |
| OLD | NEW |