mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
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 <jan@janware.com>
This commit is contained in:
parent
fd336ecdcf
commit
910f10b194
2 changed files with 3 additions and 4 deletions
|
|
@ -41,6 +41,4 @@ class Exec(Base):
|
||||||
|
|
||||||
async def _run_ssh(self, cmd: list[str], cmd_input: bytes|None, *args, **kwargs) -> Result:
|
async def _run_ssh(self, cmd: list[str], cmd_input: bytes|None, *args, **kwargs) -> Result:
|
||||||
self.__init_askpass()
|
self.__init_askpass()
|
||||||
if cmd_input is None:
|
return await run_cmd(['ssh', self.hostname, join_cmd(cmd)], cmd_input=cmd_input, throw=False)
|
||||||
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)
|
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,12 @@ def pretty_cmd(cmd: list[str], wd=None):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# See ExecContext.run() for what this function does
|
# 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:
|
if verbose is None:
|
||||||
verbose = False if ec is None else ec.verbose_default
|
verbose = False if ec is None else ec.verbose_default
|
||||||
if ec is None:
|
if ec is None:
|
||||||
from .ec.Local import Local
|
from .ec.Local import Local
|
||||||
|
interactive = cmd_input == InputMode.Interactive
|
||||||
ec = Local(verbose_default=verbose, interactive=interactive)
|
ec = Local(verbose_default=verbose, interactive=interactive)
|
||||||
return await ec.run(verbose=verbose, *args, **kwargs)
|
return await ec.run(verbose=verbose, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue