OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Client-side script to send a try job to the try server. It communicates to | 6 """Client-side script to send a try job to the try server. It communicates to |
7 the try server by either writting to a svn repository or by directly connecting | 7 the try server by either writting to a svn repository or by directly connecting |
8 to the server by HTTP. | 8 to the server by HTTP. |
9 """ | 9 """ |
10 | 10 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 if options.proxy: | 323 if options.proxy: |
324 if options.proxy.lower() == 'none': | 324 if options.proxy.lower() == 'none': |
325 # Effectively disable HTTP_PROXY or Internet settings proxy setup. | 325 # Effectively disable HTTP_PROXY or Internet settings proxy setup. |
326 proxies = {} | 326 proxies = {} |
327 else: | 327 else: |
328 proxies = {'http': options.proxy, 'https': options.proxy} | 328 proxies = {'http': options.proxy, 'https': options.proxy} |
329 | 329 |
330 logging.info('Sending by HTTP') | 330 logging.info('Sending by HTTP') |
331 logging.info(description) | 331 logging.info(description) |
332 logging.info(url) | 332 logging.info(url) |
| 333 logging.info(options.diff) |
333 if options.dry_run: | 334 if options.dry_run: |
334 print options.diff | |
335 return | 335 return |
336 logging.info(options.diff) | |
337 | 336 |
338 try: | 337 try: |
339 logging.info('Opening connection...') | 338 logging.info('Opening connection...') |
340 connection = urllib.urlopen(url, urllib.urlencode(values), proxies=proxies) | 339 connection = urllib.urlopen(url, urllib.urlencode(values), proxies=proxies) |
341 logging.info('Done') | 340 logging.info('Done') |
342 except IOError, e: | 341 except IOError, e: |
343 logging.info(str(e)) | 342 logging.info(str(e)) |
344 if (values.get('bot') and len(e.args) > 2 and | 343 if (values.get('bot') and len(e.args) > 2 and |
345 e.args[2] == 'got a bad status line'): | 344 e.args[2] == 'got a bad status line'): |
346 raise NoTryServerAccess('%s is unaccessible. Bad --bot argument?' % url) | 345 raise NoTryServerAccess('%s is unaccessible. Bad --bot argument?' % url) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 "the try bots report results to [default: %default]") | 502 "the try bots report results to [default: %default]") |
504 group.add_option("-n", "--name", | 503 group.add_option("-n", "--name", |
505 help="Descriptive name of the try job") | 504 help="Descriptive name of the try job") |
506 group.add_option("--issue", type='int', | 505 group.add_option("--issue", type='int', |
507 help="Update rietveld issue try job status") | 506 help="Update rietveld issue try job status") |
508 group.add_option("--patchset", type='int', | 507 group.add_option("--patchset", type='int', |
509 help="Update rietveld issue try job status. This is " | 508 help="Update rietveld issue try job status. This is " |
510 "optional if --issue is used, In that case, the " | 509 "optional if --issue is used, In that case, the " |
511 "latest patchset will be used.") | 510 "latest patchset will be used.") |
512 group.add_option("--dry_run", action='store_true', | 511 group.add_option("--dry_run", action='store_true', |
513 help="Just prints the diff and quits") | 512 help="Don't send the try job. This implies --verbose, so " |
| 513 "it will print the diff.") |
514 parser.add_option_group(group) | 514 parser.add_option_group(group) |
515 | 515 |
516 group = optparse.OptionGroup(parser, "Try job options") | 516 group = optparse.OptionGroup(parser, "Try job options") |
517 group.add_option("-b", "--bot", action="append", | 517 group.add_option("-b", "--bot", action="append", |
518 help="Only use specifics build slaves, ex: " | 518 help="Only use specifics build slaves, ex: " |
519 "'--bot win,layout_mac'; see the try " | 519 "'--bot win,layout_mac'; see the try " |
520 "server waterfall for the slave's name") | 520 "server waterfall for the slave's name") |
521 group.add_option("-r", "--revision", | 521 group.add_option("-r", "--revision", |
522 help="Revision to use for the try job; default: the " | 522 help="Revision to use for the try job; default: the " |
523 "revision will be determined by the try server; see " | 523 "revision will be determined by the try server; see " |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 dest="send_patch", | 604 dest="send_patch", |
605 help="Use SVN to talk to the try server") | 605 help="Use SVN to talk to the try server") |
606 group.add_option("-S", "--svn_repo", | 606 group.add_option("-S", "--svn_repo", |
607 metavar="SVN_URL", | 607 metavar="SVN_URL", |
608 help="SVN url to use to write the changes in; --use_svn is " | 608 help="SVN url to use to write the changes in; --use_svn is " |
609 "implied when using --svn_repo") | 609 "implied when using --svn_repo") |
610 parser.add_option_group(group) | 610 parser.add_option_group(group) |
611 | 611 |
612 options, args = parser.parse_args(argv) | 612 options, args = parser.parse_args(argv) |
613 | 613 |
614 # Note that the args array includes the script name, so | |
615 # a single argument results in len(args) == 2. | |
616 | |
617 # If they've asked for help, give it to them | 614 # If they've asked for help, give it to them |
618 if len(args) == 2 and args[1] == 'help': | 615 if len(args) == 1 and args[0] == 'help': |
619 parser.print_help() | 616 parser.print_help() |
620 return 0 | 617 return 0 |
621 | 618 |
622 # If they've said something confusing, don't spawn a try job until you | 619 # If they've said something confusing, don't spawn a try job until you |
623 # understand what they want. | 620 # understand what they want. |
624 if len(args) > 1: | 621 if args: |
625 plural = "" | 622 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) |
626 if len(args) > 2: | 623 |
627 plural = "s" | 624 if options.dry_run: |
628 print >> sys.stderr, ( | 625 options.verbose += 1 |
629 'Argument%s \"%s\" not understood' % (plural, ' '.join(args[1:]))) | |
630 parser.print_help() | |
631 return 1 | |
632 | 626 |
633 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' | 627 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' |
634 if not swallow_exception: | 628 if not swallow_exception: |
635 if options.verbose == 0: | 629 if options.verbose == 0: |
636 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) | 630 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) |
637 elif options.verbose == 1: | 631 elif options.verbose == 1: |
638 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) | 632 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) |
639 elif options.verbose > 1: | 633 elif options.verbose > 1: |
640 logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) | 634 logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) |
641 | 635 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 print >> sys.stderr, e | 763 print >> sys.stderr, e |
770 return 1 | 764 return 1 |
771 except gclient_utils.Error, e: | 765 except gclient_utils.Error, e: |
772 print >> sys.stderr, e | 766 print >> sys.stderr, e |
773 return 1 | 767 return 1 |
774 return 0 | 768 return 0 |
775 | 769 |
776 | 770 |
777 if __name__ == "__main__": | 771 if __name__ == "__main__": |
778 sys.exit(TryChange(None, [], False)) | 772 sys.exit(TryChange(None, [], False)) |
OLD | NEW |