def METHOD_NAME(cmd, timeout=None) -> str:
    env = os.environ.copy()
    # in windows we need to set shell=True or else PATH is ignored and subprocess.run can't find poetry
    shell = False
    if os.name == "nt":
        shell = True
    cmd_for_printing = shlex.join([str(c) for c in cmd])
    logging.debug(f"Running cmd: {cmd_for_printing}")
    try:
        result = subprocess.run(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell, timeout=timeout)
        logging.debug(f"cmd result={result}")
    except Exception as e:
        logging.warning(f"failure running cmd: {cmd_for_printing}")
        raise
    if result.returncode:
        logging.error(f"running command '{cmd_for_printing}' failed with returncode={result.returncode}, stdout={result.stdout.decode()}, stderr={result.stderr.decode()}")
        raise Exception(f"Error running robusta cli command: {result.args}")
    return result.stdout.decode()