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 """Client-side script to send a try job to the try server. It communicates to | 5 """Client-side script to send a try job to the try server. It communicates to |
6 the try server by either writting to a svn repository or by directly connecting | 6 the try server by either writting to a svn repository or by directly connecting |
7 to the server by HTTP. | 7 to the server by HTTP. |
8 """ | 8 """ |
9 | 9 |
10 import datetime | 10 import datetime |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 const=_SendChangeSVN, | 593 const=_SendChangeSVN, |
594 dest="send_patch", | 594 dest="send_patch", |
595 help="Use SVN to talk to the try server") | 595 help="Use SVN to talk to the try server") |
596 group.add_option("-S", "--svn_repo", | 596 group.add_option("-S", "--svn_repo", |
597 metavar="SVN_URL", | 597 metavar="SVN_URL", |
598 help="SVN url to use to write the changes in; --use_svn is " | 598 help="SVN url to use to write the changes in; --use_svn is " |
599 "implied when using --svn_repo") | 599 "implied when using --svn_repo") |
600 parser.add_option_group(group) | 600 parser.add_option_group(group) |
601 | 601 |
602 options, args = parser.parse_args(argv) | 602 options, args = parser.parse_args(argv) |
603 if len(args) == 1 and args[0] == 'help': | 603 |
604 # Note that the args array includes the script name, so | |
605 # a single argument results in len(args) == 2. | |
Evan Martin
2010/07/29 23:36:19
Wow, I have probably written the same bug a millio
| |
606 | |
607 # If they've asked for help, give it to them | |
608 if len(args) == 2 and args[1] == 'help': | |
604 parser.print_help() | 609 parser.print_help() |
610 return 0 | |
611 | |
612 # If they've said something confusing, don't spawn a try job until you | |
613 # understand what they want. | |
614 if len(args) > 1: | |
615 plural = "" | |
616 if len(args) > 2: | |
617 plural = "s" | |
618 print "Argument%s \"%s\" not understood" % (plural, " ".join(args[1:])) | |
619 parser.print_help() | |
620 return 1 | |
605 | 621 |
606 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' | 622 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' |
607 if not swallow_exception: | 623 if not swallow_exception: |
608 if options.verbose == 0: | 624 if options.verbose == 0: |
609 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) | 625 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) |
610 elif options.verbose == 1: | 626 elif options.verbose == 1: |
611 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) | 627 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) |
612 elif options.verbose > 1: | 628 elif options.verbose > 1: |
613 logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) | 629 logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) |
614 | 630 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 except (InvalidScript, NoTryServerAccess), e: | 752 except (InvalidScript, NoTryServerAccess), e: |
737 if swallow_exception: | 753 if swallow_exception: |
738 return 1 | 754 return 1 |
739 print e | 755 print e |
740 return 1 | 756 return 1 |
741 return 0 | 757 return 0 |
742 | 758 |
743 | 759 |
744 if __name__ == "__main__": | 760 if __name__ == "__main__": |
745 sys.exit(TryChange(None, [], False)) | 761 sys.exit(TryChange(None, [], False)) |
OLD | NEW |