process.py 文件源码

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

项目:BAG_framework 作者: ucb-art 项目源码 文件源码
def run_and_wait(args, timeout=None, logfile=None, append=False,
                 env=None, cwd=None):
    """Run a command in a subprocess, then wait for it to finish.

    Parameters
    ----------
    args : string or list[string]
        the command to run.  Should be either a command string or a list
        of command string and its arguments as strings.  A list is preferred;
        see Python subprocess documentation.
    timeout : float or None
        the amount of time to wait for the command to finish, in seconds.
        If None, waits indefinitely.
    logfile : string or None
        If given, stdout and stderr will be written to this file.
    append : bool
        True to append to the logfile.  Defaults to False.
    env : dict[string, any]
        If not None, environment variables of the subprocess will be set
        according to this dictionary instead of inheriting from current
        process.
    cwd : string or None
        The current working directory of the subprocess.

    Returns
    -------
    output : string
        the standard output and standard error from the command.

    Raises
    ------
    subprocess.CalledProcessError
        if any error occurred in the subprocess.
    """
    output = subprocess.check_output(args, stderr=subprocess.STDOUT,
                                     timeout=timeout, env=env, cwd=cwd)
    output = output.decode(encoding=bag_encoding, errors=bag_codec_error)

    if logfile is not None:
        write_file(logfile, output, append=append)

    return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号