Exemplo n.º 1
0
def run_and_log_output(cmd_string, *args, **kwargs):
    """
    Runs a command with iterpipes and logs the output
    """
    c = iterpipes.cmd(cmd_string, bufsize=128, *args, **kwargs)
    logging.info('Running %s', iterpipes.format(cmd_string, args))
    out = iterpipes.run(c)
    for line in out:
        logging.info(line)
Exemplo n.º 2
0
def test_format_args_count():
    eq_(format('f', []), 'f')
    eq_(format('f {}', ['x']), 'f x')
    assert_raises(TypeError, lambda: format('f {} {}', ['a']))
    assert_raises(TypeError, lambda: format('f {} {}', ['a', 'b', 'c']))
Exemplo n.º 3
0
def test_subst_curly_brackets():
    eq_(format('echo {} | wc {}', ['{}', '-l']), 'echo {} | wc -l')
    eq_(format('echo {{}}', ['x']), 'echo {x}')
    eq_(format('echo {{}}', ['{}']), 'echo {{}}')