From 910f10b194b713e1ca3b818c8ddf04859a22e38e Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 17 Apr 2026 18:11:43 +0200 Subject: [PATCH] lib.util.run_cmd(): Remove parameter interactive run_cmd() is a thin layer over the public ExecContext API, which falls back to using a Local instance if not other ExecContext is specified explicitly. Both the default Local context as the subsequent call to run() should have the same idea about interactivity, so allowing to specify it in two parameters ("interactive" and "cmd_input") is a bad idea. Remove "interactive". Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/ec/ssh/Exec.py | 4 +--- src/python/jw/pkg/lib/util.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/python/jw/pkg/lib/ec/ssh/Exec.py b/src/python/jw/pkg/lib/ec/ssh/Exec.py index c566f9e2..c53362e4 100644 --- a/src/python/jw/pkg/lib/ec/ssh/Exec.py +++ b/src/python/jw/pkg/lib/ec/ssh/Exec.py @@ -41,6 +41,4 @@ class Exec(Base): async def _run_ssh(self, cmd: list[str], cmd_input: bytes|None, *args, **kwargs) -> Result: self.__init_askpass() - if cmd_input is None: - cmd_input = InputMode.Interactive if self.interactive else InputMode.NonInteractive - return await run_cmd(['ssh', self.hostname, join_cmd(cmd)], cmd_input=cmd_input, interactive=self.interactive, throw=False) + return await run_cmd(['ssh', self.hostname, join_cmd(cmd)], cmd_input=cmd_input, throw=False) diff --git a/src/python/jw/pkg/lib/util.py b/src/python/jw/pkg/lib/util.py index a0d3bef6..7798988b 100644 --- a/src/python/jw/pkg/lib/util.py +++ b/src/python/jw/pkg/lib/util.py @@ -33,11 +33,12 @@ def pretty_cmd(cmd: list[str], wd=None): return ret # See ExecContext.run() for what this function does -async def run_cmd(*args, ec: ExecContext|None=None, verbose: bool|None=None, interactive: bool=False, **kwargs) -> Result: +async def run_cmd(*args, ec: ExecContext|None=None, verbose: bool|None=None, cmd_input: Input=InputMode.NonInteractive, **kwargs) -> Result: if verbose is None: verbose = False if ec is None else ec.verbose_default if ec is None: from .ec.Local import Local + interactive = cmd_input == InputMode.Interactive ec = Local(verbose_default=verbose, interactive=interactive) return await ec.run(verbose=verbose, *args, **kwargs)