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:
Jan Lindemann 2026-03-23 13:13:55 +01:00
commit 21e67291b5
6 changed files with 12 additions and 14 deletions

View file

@ -30,14 +30,14 @@ async def run_dpkg(args: list[str], sudo: bool=False, ec: ExecContext=None): # e
cmd.extend(args)
if sudo:
return await run_sudo(cmd, ec=ec)
return await run_cmd(cmd, ec=ec)
return (await run_cmd(cmd, ec=ec)).decode()
async def run_dpkg_query(args: list[str], sudo: bool=False, ec: ExecContext=None): # export
cmd = ['/usr/bin/dpkg-query']
cmd.extend(args)
if sudo:
return await run_sudo(cmd)
return await run_cmd(cmd, ec=ec)
return (await run_cmd(cmd, ec=ec)).decode()
async def query_packages(names: Iterable[str] = [], ec: ExecContext=None) -> Iterable[Package]: # export
fmt_str = '|'.join([(f'${{{tag}}}' if tag else '') for tag in meta_map().values()]) + r'\n'

View file

@ -38,8 +38,8 @@ async def query_packages(names: Iterable[str] = [], ec: ExecContext=None) -> Ite
if not names:
opts.append('-a')
specs, stderr, status = await run_rpm([*opts, *names], throw=True, sudo=False, ec=ec)
return Package.parse_specs_str(specs)
return Package.parse_specs_str(specs.decode())
async def list_files(pkg: str, ec: ExecContext=None) -> list[str]: # export
file_list_str, stderr, status = await run_rpm(['-ql', pkg], throw=True, sudo=False, ec=ec)
return file_list_str.splitlines()
stdout, stderr, status = await run_rpm(['-ql', pkg], throw=True, sudo=False, ec=ec)
return stdout.decode().splitlines()