cli.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:txjuju 作者: juju 项目源码 文件源码
def spawn_process(executable, args, env, outfile=None):
    """Spawn a process using Twisted reactor.

    Return a deferred which will be called with process stdout, stderr
    and exit code.  If outfile is provided then the stdout and stderr
    stings will be empty.

    Note: this is a variant of landscape.lib.twisted_util.spawn_process
    that supports streaming to a file.
    """
    list_args = [executable]
    list_args.extend(args)

    logging.info("running {!r}".format(" ".join(list_args)))
    import pprint
    logging.info("OS env:\n" + pprint.pformat(env))

    result = Deferred()
    if outfile is None:
        protocol = AllOutputProcessProtocol(result)
    else:
        protocol = StreamToFileProcessProtocol(result, outfile)
    reactor.spawnProcess(protocol, executable, args=list_args, env=env)
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号