mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 17:45:55 +02:00
Fix: Decode run_cmd() result
Since commit 02697af5, ExecContext.run() returns bytes for stdout and
stderr and fixes that in calling code. The thing it did not fix was
the code calling run_cmd(), which also made return bytes. This commit
catches up on that.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
fd35fa0871
commit
21e67291b5
6 changed files with 12 additions and 14 deletions
|
|
@ -32,7 +32,7 @@ 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, **kwargs) -> tuple[str|bytes|None, str|bytes|None]:
|
||||
async def run_cmd(*args, ec: ExecContext|None=None, verbose: bool|None=None, **kwargs) -> Result:
|
||||
if verbose is None:
|
||||
verbose = False if ec is None else ec.verbose_default
|
||||
if ec is None:
|
||||
|
|
@ -47,7 +47,7 @@ async def run_curl(args: list[str], parse_json: bool=True, wd=None, throw=None,
|
|||
if not verbose:
|
||||
cmd.append('-s')
|
||||
cmd.extend(args)
|
||||
ret, stderr, status = await run_cmd(cmd, wd=wd, throw=throw, verbose=verbose, cmd_input=cmd_input, ec=ec)
|
||||
ret, stderr, status = await run_cmd(cmd, wd=wd, throw=throw, verbose=verbose, cmd_input=cmd_input, ec=ec).decode()
|
||||
if parse_json:
|
||||
try:
|
||||
ret = json.loads(ret)
|
||||
|
|
@ -82,7 +82,7 @@ async def run_askpass(askpass_env: list[str], key: AskpassKey, host: str|None=No
|
|||
continue # Can't get user name from SSH_ASKPASS
|
||||
case AskpassKey.Password:
|
||||
exe_arg += 'Password'
|
||||
ret, stderr, status = await run_cmd([exe, exe_arg], throw=False, ec=ec)
|
||||
ret, stderr, status = await run_cmd([exe, exe_arg], throw=False, ec=ec).decode()
|
||||
if ret is not None:
|
||||
return ret
|
||||
return None
|
||||
|
|
@ -141,7 +141,7 @@ async def get_profile_env(throw: bool=True, keep: Iterable[str]|bool=False, ec:
|
|||
cmd = ['/usr/bin/env', '-i', '/bin/bash', '-lc', 'env -0']
|
||||
result = await run_cmd(cmd, throw=throw, verbose=True, env=env, ec=ec)
|
||||
ret: dict[str, str] = {}
|
||||
for entry in result.stdout.split(b"\0"):
|
||||
for entry in result.stdout.rstrip(b"\0").split(b"\0"):
|
||||
if not entry:
|
||||
continue
|
||||
key, val = entry.split(b"=", 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue