cli: set needs_user_terminal for all ssh commands

This commit is contained in:
DavHau
2024-10-23 19:40:31 +07:00
parent 9452bb4b92
commit 08fb34aa01
6 changed files with 14 additions and 4 deletions

View File

@@ -154,7 +154,7 @@ def show_block_devices(options: BlockDeviceOptions) -> Blockdevices:
"PATH,NAME,RM,SIZE,RO,MOUNTPOINTS,TYPE,ID-LINK",
],
)
proc = run_no_stdout(cmd)
proc = run_no_stdout(cmd, needs_user_terminal=True)
res = proc.stdout.strip()
blk_info: dict[str, Any] = json.loads(res)

View File

@@ -194,6 +194,7 @@ def run_no_stdout(
log: Log = Log.STDERR,
check: bool = True,
error_msg: str | None = None,
needs_user_terminal: bool = False,
) -> CmdOut:
"""
Like run, but automatically suppresses stdout, if not in DEBUG log level.
@@ -204,4 +205,11 @@ def run_no_stdout(
if logging.getLogger(__name__.split(".")[0]).isEnabledFor(logging.DEBUG):
return run(cmd, env=env, log=log, check=check, error_msg=error_msg)
log = Log.NONE
return run(cmd, env=env, log=log, check=check, error_msg=error_msg)
return run(
cmd,
env=env,
log=log,
check=check,
error_msg=error_msg,
needs_user_terminal=needs_user_terminal,
)

View File

@@ -41,6 +41,7 @@ def upload_secrets(machine: Machine) -> None:
],
),
log=Log.BOTH,
needs_user_terminal=True,
)

View File

@@ -157,7 +157,7 @@ def generate_machine_hardware_info(opts: HardwareGenerateOptions) -> HardwareRep
*config_command,
],
)
out = run(cmd)
out = run(cmd, needs_user_terminal=True)
if out.returncode != 0:
log.error(out)
msg = f"Failed to inspect {opts.machine}. Address: {opts.target_host}"

View File

@@ -121,7 +121,7 @@ def check_machine_online(
],
)
try:
proc = run_no_stdout(cmd)
proc = run_no_stdout(cmd, needs_user_terminal=True)
if proc.returncode != 0:
return "Offline"
except ClanCmdError:

View File

@@ -42,6 +42,7 @@ def upload_secrets(machine: Machine) -> None:
],
),
log=Log.BOTH,
needs_user_terminal=True,
)