fix: don't prompt users unless we have a TTY

This can break automated runs (which earlier worked)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-12-02 20:49:11 +05:30
parent b6cfedaa1c
commit 267e58a819
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
2 changed files with 3 additions and 2 deletions

View file

@ -129,7 +129,7 @@ def get_root_connection():
frappe.flags.root_login = (
frappe.conf.get("mariadb_root_login")
or frappe.conf.get("root_login")
or input("Enter mysql super user [root]: ")
or (sys.__stdin__.isatty() and input("Enter mysql super user [root]: "))
or "root"
)

View file

@ -60,13 +60,14 @@ def import_db_from_sql(source_sql=None, verbose=False):
def get_root_connection():
if not frappe.local.flags.root_connection:
import sys
from getpass import getpass
if not frappe.flags.root_login:
frappe.flags.root_login = (
frappe.conf.get("postgres_root_login")
or frappe.conf.get("root_login")
or input("Enter postgres super user [postgres]: ")
or (sys.__stdin__.isatty() and input("Enter postgres super user [postgres]: "))
or "postgres"
)