def run_command(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False,
                cwd=None, env=None):
    assert isinstance(cmd, (list, tuple) + six.string_types)

    if not env:
        env = os.environ.copy()

    process = subprocess.Popen(cmd, stdin=stdin, stdout=stdout, stderr=stderr,
                               env=env, cwd=cwd, shell=shell)
    stdout, stderr = process.communicate()
    exit_code = process.returncode

    return (exit_code, stdout, stderr)
Run the provided command in a subprocess and wait until it completes.
dataset/ETHPy150Open StackStorm/st2/st2common/st2common/util/shell.py/run_command