def run(cmd, cwd=None, env=None, timeout=None, stream=False, warn_only=False):
    """
    :param cmd: command to run
    :param cwd: change dir into before execute, default is current dir
    :param env: environments to pass to subprocess
    :param timeout: timeout
    :param stream: stream output, default is False, block until finished
    :param warn_only: default False, set to True to allow unsuccessful result
    """
    proc = Proc(
        expand_args(cmd),
        os.path.realpath(cwd or os.getcwd()),
        env=env or {},
        timeout=timeout or DEFAULT_TIMEOUT
    )

    if not stream:
        proc.block(warn_only=warn_only)
    return proc