Exemplo n.º 1
0
def _GetCommandOutput(command_name, command_argv):
    orig_stdout = sys.stdout
    orig_stderr = sys.stderr
    new_stdout = six.StringIO()
    new_stderr = six.StringIO()
    try:
        sys.stdout = new_stdout
        sys.stderr = new_stderr
        oauth2l.main(['oauth2l', command_name] + command_argv)
    finally:
        sys.stdout = orig_stdout
        sys.stderr = orig_stderr
    new_stdout.seek(0)
    return new_stdout.getvalue().rstrip()
Exemplo n.º 2
0
def _GetCommandOutput(t, command_name, command_argv):
    global _OAUTH2L_MAIN_RUN  # pylint: disable=global-statement
    if not _OAUTH2L_MAIN_RUN:
        oauth2l.main(None)
        _OAUTH2L_MAIN_RUN = True
    command = appcommands.GetCommandByName(command_name)
    if command is None:
        t.fail('Unknown command: %s' % command_name)
    orig_stdout = sys.stdout
    new_stdout = six.StringIO()
    try:
        sys.stdout = new_stdout
        command.CommandRun([command_name] + command_argv)
    finally:
        sys.stdout = orig_stdout
        FLAGS.Reset()
    new_stdout.seek(0)
    return new_stdout.getvalue().rstrip()
Exemplo n.º 3
0
def _GetCommandOutput(t, command_name, command_argv):
    global _OAUTH2L_MAIN_RUN  # pylint: disable=global-statement
    if not _OAUTH2L_MAIN_RUN:
        oauth2l.main(None)
        _OAUTH2L_MAIN_RUN = True
    command = appcommands.GetCommandByName(command_name)
    if command is None:
        t.fail('Unknown command: %s' % command_name)
    orig_stdout = sys.stdout
    new_stdout = six.StringIO()
    try:
        sys.stdout = new_stdout
        command.CommandRun([command_name] + command_argv)
    finally:
        sys.stdout = orig_stdout
        FLAGS.Reset()
    new_stdout.seek(0)
    return new_stdout.getvalue().rstrip()