INNER CODE UNIT · Python
ask_yes
LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:231
def ask_yes(prompt):
"""y/N prompt; without a terminal to ask, the answer is no.
The isatty check is not cosmetic: over an ssh session with no tty, stdin
stays open without ever delivering a line, so input() blocks forever
instead of raising EOFError. A script that hangs is worse than one that
declines -- use --yes to answer up front.
"""
if not sys.stdin.isatty():
print(prompt + " [y/N] no (not a terminal; use --yes)")
return False
try:
return input(prompt + " [y/N] ").strip().lower() == "y"
except EOFError:
return False
def confirm(prompt, assume_yes=False):