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 """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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 values.append(('patchlevel', options.patchlevel)) | 306 values.append(('patchlevel', options.patchlevel)) |
307 if options.issue: | 307 if options.issue: |
308 values.append(('issue', options.issue)) | 308 values.append(('issue', options.issue)) |
309 if options.patchset: | 309 if options.patchset: |
310 values.append(('patchset', options.patchset)) | 310 values.append(('patchset', options.patchset)) |
311 if options.target: | 311 if options.target: |
312 values.append(('target', options.target)) | 312 values.append(('target', options.target)) |
313 if options.project: | 313 if options.project: |
314 values.append(('project', options.project)) | 314 values.append(('project', options.project)) |
315 | 315 |
316 for bot in options.bot: | 316 filters = ','.join(options.testfilter) |
317 values.append(('bot', bot)) | 317 if filters: |
318 for t in options.testfilter: | 318 for bot in options.bot: |
319 values.append(('testfilter', t)) | 319 if ':' in bot: |
| 320 raise ValueError( |
| 321 'Can\'t use both --testfilter and --bot builder:test formats ' |
| 322 'at the same time') |
| 323 else: |
| 324 values.append(('bot', '%s:%s' % (bot, filters))) |
| 325 else: |
| 326 for bot in options.bot: |
| 327 values.append(('bot', bot)) |
320 return values | 328 return values |
321 | 329 |
322 | 330 |
323 def _SendChangeHTTP(options): | 331 def _SendChangeHTTP(options): |
324 """Send a change to the try server using the HTTP protocol.""" | 332 """Send a change to the try server using the HTTP protocol.""" |
325 if not options.host: | 333 if not options.host: |
326 raise NoTryServerAccess('Please use the --host option to specify the try ' | 334 raise NoTryServerAccess('Please use the --host option to specify the try ' |
327 'server host to connect to.') | 335 'server host to connect to.') |
328 if not options.port: | 336 if not options.port: |
329 raise NoTryServerAccess('Please use the --port option to specify the try ' | 337 raise NoTryServerAccess('Please use the --port option to specify the try ' |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/') | 489 new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/') |
482 if diff[i].startswith('--- '): | 490 if diff[i].startswith('--- '): |
483 file_path = new_file.split('\t')[0].strip() | 491 file_path = new_file.split('\t')[0].strip() |
484 if file_path.startswith('a/'): | 492 if file_path.startswith('a/'): |
485 file_path = file_path[2:] | 493 file_path = file_path[2:] |
486 changed_files.append(('M', file_path)) | 494 changed_files.append(('M', file_path)) |
487 diff[i] = diff[i][0:4] + new_file | 495 diff[i] = diff[i][0:4] + new_file |
488 return (diff, changed_files) | 496 return (diff, changed_files) |
489 | 497 |
490 | 498 |
491 def TryChange(argv, | 499 def gen_parser(prog): |
492 change, | |
493 swallow_exception, | |
494 prog=None, | |
495 extra_epilog=None): | |
496 """ | |
497 Args: | |
498 argv: Arguments and options. | |
499 change: Change instance corresponding to the CL. | |
500 swallow_exception: Whether we raise or swallow exceptions. | |
501 """ | |
502 # Parse argv | 500 # Parse argv |
503 parser = optparse.OptionParser(usage=USAGE, | 501 parser = optparse.OptionParser(usage=USAGE, |
504 version=__version__, | 502 version=__version__, |
505 prog=prog) | 503 prog=prog) |
506 epilog = EPILOG % { 'prog': prog } | |
507 if extra_epilog: | |
508 epilog += extra_epilog | |
509 parser.epilog = epilog | |
510 # Remove epilog formatting | |
511 parser.format_epilog = lambda x: parser.epilog | |
512 parser.add_option("-v", "--verbose", action="count", default=0, | 504 parser.add_option("-v", "--verbose", action="count", default=0, |
513 help="Prints debugging infos") | 505 help="Prints debugging infos") |
514 group = optparse.OptionGroup(parser, "Result and status") | 506 group = optparse.OptionGroup(parser, "Result and status") |
515 group.add_option("-u", "--user", default=getpass.getuser(), | 507 group.add_option("-u", "--user", default=getpass.getuser(), |
516 help="Owner user name [default: %default]") | 508 help="Owner user name [default: %default]") |
517 group.add_option("-e", "--email", | 509 group.add_option("-e", "--email", |
518 default=os.environ.get('TRYBOT_RESULTS_EMAIL_ADDRESS', | 510 default=os.environ.get('TRYBOT_RESULTS_EMAIL_ADDRESS', |
519 os.environ.get('EMAIL_ADDRESS')), | 511 os.environ.get('EMAIL_ADDRESS')), |
520 help="Email address where to send the results. Use either " | 512 help="Email address where to send the results. Use either " |
521 "the TRYBOT_RESULTS_EMAIL_ADDRESS environment " | 513 "the TRYBOT_RESULTS_EMAIL_ADDRESS environment " |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 group.add_option("--use_svn", | 621 group.add_option("--use_svn", |
630 action="store_const", | 622 action="store_const", |
631 const=_SendChangeSVN, | 623 const=_SendChangeSVN, |
632 dest="send_patch", | 624 dest="send_patch", |
633 help="Use SVN to talk to the try server") | 625 help="Use SVN to talk to the try server") |
634 group.add_option("-S", "--svn_repo", | 626 group.add_option("-S", "--svn_repo", |
635 metavar="SVN_URL", | 627 metavar="SVN_URL", |
636 help="SVN url to use to write the changes in; --use_svn is " | 628 help="SVN url to use to write the changes in; --use_svn is " |
637 "implied when using --svn_repo") | 629 "implied when using --svn_repo") |
638 parser.add_option_group(group) | 630 parser.add_option_group(group) |
| 631 return parser |
| 632 |
| 633 |
| 634 def TryChange(argv, |
| 635 change, |
| 636 swallow_exception, |
| 637 prog=None, |
| 638 extra_epilog=None): |
| 639 """ |
| 640 Args: |
| 641 argv: Arguments and options. |
| 642 change: Change instance corresponding to the CL. |
| 643 swallow_exception: Whether we raise or swallow exceptions. |
| 644 """ |
| 645 parser = gen_parser(prog) |
| 646 epilog = EPILOG % { 'prog': prog } |
| 647 if extra_epilog: |
| 648 epilog += extra_epilog |
| 649 parser.epilog = epilog |
| 650 # Remove epilog formatting |
| 651 parser.format_epilog = lambda x: parser.epilog |
639 | 652 |
640 options, args = parser.parse_args(argv) | 653 options, args = parser.parse_args(argv) |
641 | 654 |
642 # If they've asked for help, give it to them | 655 # If they've asked for help, give it to them |
643 if len(args) == 1 and args[0] == 'help': | 656 if len(args) == 1 and args[0] == 'help': |
644 parser.print_help() | 657 parser.print_help() |
645 return 0 | 658 return 0 |
646 | 659 |
647 # If they've said something confusing, don't spawn a try job until you | 660 # If they've said something confusing, don't spawn a try job until you |
648 # understand what they want. | 661 # understand what they want. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 return 1 | 837 return 1 |
825 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 838 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
826 print >> sys.stderr, e | 839 print >> sys.stderr, e |
827 return 1 | 840 return 1 |
828 return 0 | 841 return 0 |
829 | 842 |
830 | 843 |
831 if __name__ == "__main__": | 844 if __name__ == "__main__": |
832 fix_encoding.fix_encoding() | 845 fix_encoding.fix_encoding() |
833 sys.exit(TryChange(None, None, False)) | 846 sys.exit(TryChange(None, None, False)) |
OLD | NEW |