Beispiel #1
0
def _DisplayError(component_trace):
    """Prints the Fire trace and the error to stdout."""
    result = component_trace.GetResult()

    output = []
    show_help = False
    for help_flag in ('-h', '--help'):
        if help_flag in component_trace.elements[-1].args:
            show_help = True

    if show_help:
        command = '{cmd} -- --help'.format(cmd=component_trace.GetCommand())
        print('INFO: Showing help with the command {cmd}.\n'.format(
            cmd=pipes.quote(command)),
              file=sys.stderr)
        help_text = helptext.HelpText(result,
                                      trace=component_trace,
                                      verbose=component_trace.verbose)
        output.append(help_text)
        Display(output, out=sys.stderr)
    else:
        print(formatting.Error('ERROR: ') +
              component_trace.elements[-1].ErrorAsStr(),
              file=sys.stderr)
        error_text = helptext.UsageText(result,
                                        trace=component_trace,
                                        verbose=component_trace.verbose)
        print(error_text, file=sys.stderr)
Beispiel #2
0
def _DisplayError(component_trace):
    """Prints the Fire trace and the error to stdout."""
    output = []
    for help_flag in ('-h', '--help'):
        if help_flag in component_trace.elements[-1].args:
            command = '{cmd} -- --help'.format(
                cmd=component_trace.GetCommand())
            message = 'INFO: Showing help with the command {cmd}.\n'.format(
                cmd=pipes.quote(command))
            output.append(message)
    output.append(
        formatting.Error('ERROR: ') +
        component_trace.elements[-1].ErrorAsStr())
    result = component_trace.GetResult()
    help_string = helptext.HelpString(result, component_trace,
                                      component_trace.verbose)
    output.append(help_string)
    Display(output)