Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: git_cl.py

Issue 1799203002: git cl try-results: make color force-able. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 max(len(str(get_builder(b))) for b in builds.itervalues())) 446 max(len(str(get_builder(b))) for b in builds.itervalues()))
447 def get_name(b): 447 def get_name(b):
448 return name_fmt % get_builder(b) 448 return name_fmt % get_builder(b)
449 449
450 def sort_key(b): 450 def sort_key(b):
451 return b['status'], b.get('result'), get_name(b), b.get('url') 451 return b['status'], b.get('result'), get_name(b), b.get('url')
452 452
453 def pop(title, f, color=None, **kwargs): 453 def pop(title, f, color=None, **kwargs):
454 """Pop matching builds from `builds` dict and print them.""" 454 """Pop matching builds from `builds` dict and print them."""
455 455
456 if not sys.stdout.isatty() or color is None: 456 if not options.color or color is None:
457 colorize = str 457 colorize = str
458 else: 458 else:
459 colorize = lambda x: '%s%s%s' % (color, x, Fore.RESET) 459 colorize = lambda x: '%s%s%s' % (color, x, Fore.RESET)
460 460
461 result = [] 461 result = []
462 for b in builds.values(): 462 for b in builds.values():
463 if all(b.get(k) == v for k, v in kwargs.iteritems()): 463 if all(b.get(k) == v for k, v in kwargs.iteritems()):
464 builds.pop(b['id']) 464 builds.pop(b['id'])
465 result.append(b) 465 result.append(b)
466 if result: 466 if result:
(...skipping 3078 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 for builder in sorted(builders): 3545 for builder in sorted(builders):
3546 print ' %*s: %s' % (length, builder, ','.join(builders[builder])) 3546 print ' %*s: %s' % (length, builder, ','.join(builders[builder]))
3547 return 0 3547 return 0
3548 3548
3549 3549
3550 def CMDtry_results(parser, args): 3550 def CMDtry_results(parser, args):
3551 group = optparse.OptionGroup(parser, "Try job results options") 3551 group = optparse.OptionGroup(parser, "Try job results options")
3552 group.add_option( 3552 group.add_option(
3553 "-p", "--patchset", type=int, help="patchset number if not current.") 3553 "-p", "--patchset", type=int, help="patchset number if not current.")
3554 group.add_option( 3554 group.add_option(
3555 "--print-master", action='store_true', help="print master name as well") 3555 "--print-master", action='store_true', help="print master name as well.")
3556 group.add_option(
3557 "--color", action='store_true', default=sys.stdout.isatty(),
3558 help="force color output, useful when piping output.")
3556 group.add_option( 3559 group.add_option(
3557 "--buildbucket-host", default='cr-buildbucket.appspot.com', 3560 "--buildbucket-host", default='cr-buildbucket.appspot.com',
3558 help="Host of buildbucket. The default host is %default.") 3561 help="Host of buildbucket. The default host is %default.")
3559 parser.add_option_group(group) 3562 parser.add_option_group(group)
3560 auth.add_auth_options(parser) 3563 auth.add_auth_options(parser)
3561 options, args = parser.parse_args(args) 3564 options, args = parser.parse_args(args)
3562 if args: 3565 if args:
3563 parser.error('Unrecognized args: %s' % ' '.join(args)) 3566 parser.error('Unrecognized args: %s' % ' '.join(args))
3564 3567
3565 auth_config = auth.extract_auth_config_from_options(options) 3568 auth_config = auth.extract_auth_config_from_options(options)
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3983 if __name__ == '__main__': 3986 if __name__ == '__main__':
3984 # These affect sys.stdout so do it outside of main() to simplify mocks in 3987 # These affect sys.stdout so do it outside of main() to simplify mocks in
3985 # unit testing. 3988 # unit testing.
3986 fix_encoding.fix_encoding() 3989 fix_encoding.fix_encoding()
3987 colorama.init() 3990 colorama.init()
3988 try: 3991 try:
3989 sys.exit(main(sys.argv[1:])) 3992 sys.exit(main(sys.argv[1:]))
3990 except KeyboardInterrupt: 3993 except KeyboardInterrupt:
3991 sys.stderr.write('interrupted\n') 3994 sys.stderr.write('interrupted\n')
3992 sys.exit(1) 3995 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698