def CMDtry_results(parser, args):
    group = optparse.OptionGroup(parser, 'Try job results options')
    group.add_option('-p', '--patchset', type=int, help='patchset number if not current.')
    group.add_option('--print-master', action='store_true', help='print master name as well.')
    group.add_option('--color', action='store_true', default=setup_color.IS_TTY, help='force color output, useful when piping output.')
    group.add_option('--buildbucket-host', default='cr-buildbucket.appspot.com', help='Host of buildbucket. The default host is %default.')
    parser.add_option_group(group)
    auth.add_auth_options(parser)
    (options, args) = parser.parse_args(args)
    if args:
        parser.error(('Unrecognized args: %s' % ' '.join(args)))
    auth_config = auth.extract_auth_config_from_options(options)
    cl = Changelist(auth_config=auth_config)
    if (not cl.GetIssue()):
        parser.error('Need to upload first')
    if (not options.patchset):
        options.patchset = cl.GetMostRecentPatchset()
        if (options.patchset and (options.patchset != cl.GetPatchset())):
            print(('\nWARNING Mismatch between local config and server. Did a previous upload fail?\ngit-cl try always uses latest patchset from rietveld. Continuing using\npatchset %s.\n' % options.patchset))
    try:
        jobs = fetch_try_jobs(auth_config, cl, options)
    except BuildbucketResponseException as ex:
        print(('Buildbucket error: %s' % ex))
        return 1
    except Exception as e:
        stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc())
        print(('ERROR: Exception when trying to fetch tryjobs: %s\n%s' % (e, stacktrace)))
        return 1
    print_tryjobs(options, jobs)
    return 0
def CMDtry_results(parser, args):
    group = optparse.OptionGroup(parser, 'Try job results options')
    group.add_option('-p', '--patchset', type=int, help='patchset number if not current.')
    group.add_option('--print-master', action='store_true', help='print master name as well.')
    group.add_option('--color', action='store_true', default=setup_color.IS_TTY, help='force color output, useful when piping output.')
    group.add_option('--buildbucket-host', default='cr-buildbucket.appspot.com', help='Host of buildbucket. The default host is %default.')
    parser.add_option_group(group)
    auth.add_auth_options(parser)
    (options, args) = parser.parse_args(args)
    if args:
        parser.error(('Unrecognized args: %s' % ' '.join(args)))
    auth_config = auth.extract_auth_config_from_options(options)
    cl = Changelist(auth_config=auth_config)
    if (not cl.GetIssue()):
        parser.error('Need to upload first')
    if (not options.patchset):
        options.patchset = cl.GetMostRecentPatchset()
        if (options.patchset and (options.patchset != cl.GetPatchset())):
            print(('\nWARNING Mismatch between local config and server. Did a previous upload fail?\ngit-cl try always uses latest patchset from rietveld. Continuing using\npatchset %s.\n' % options.patchset))
    try:
        jobs = fetch_try_jobs(auth_config, cl, options)
    except BuildbucketResponseException as ex:
        print(('Buildbucket error: %s' % ex))
        return 1
    except Exception as e:
        stacktrace = (.join(traceback.format_stack()) + traceback.format_exc())
        print(('ERROR: Exception when trying to fetch tryjobs: %s\n%s' % (e, stacktrace)))
        return 1
    print_tryjobs(options, jobs)
    return 0