def METHOD_NAME(cmd, stdin=None):
    shell = isinstance(cmd, str)
    with subprocess.Popen(
        cmd,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        stdin=subprocess.PIPE if stdin else None,
        shell=shell,
    ) as p:
        stdout, stderr = p.communicate(stdin)
        if stdout.strip().decode() == "The agent has no identities.":
            return ""
        if p.returncode:
            message = stderr.strip() + b"\n" + stdout.strip()
            raise Exception(message.strip().decode())
        return stdout