mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-28 14:05:25 +02:00
run_cmd() and friends: Make args a list[str]
This is a code maintenance commit: some run_xxx() helper functions take a string, some a list, and some just digest all arguments and pass them on as a list to exec() to be executed. That's highly inconsistent. This commit changes that to list-only. Except for the run_cmd() method of SSHClient, which is still run as a shell method, because, erm, it's a shell. Might be changed in the future for consistency reasons. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
fbeefa2d9e
commit
b81406e11a
12 changed files with 22 additions and 23 deletions
|
|
@ -6,13 +6,12 @@ from ....lib.util import run_cmd, run_sudo
|
|||
|
||||
from .Package import Package
|
||||
|
||||
async def run_rpm(*args, sudo=False): # export
|
||||
async def run_rpm(args: list[str], sudo: bool=False): # export
|
||||
cmd = ['/usr/bin/rpm']
|
||||
cmd.extend(args)
|
||||
# FIXME: usage of run_xxx() (unpacked vs regular list is highly inconsistent)
|
||||
if sudo:
|
||||
return await run_sudo(cmd)
|
||||
return await run_cmd(*cmd)
|
||||
return await run_cmd(cmd)
|
||||
|
||||
async def all_installed_packages() -> Iterable[Package]: # export
|
||||
ret: list[Package] = []
|
||||
|
|
@ -25,7 +24,7 @@ async def all_installed_packages() -> Iterable[Package]: # export
|
|||
opts.append('--queryformat')
|
||||
tag_str = '|'.join([f'%{{{tag}}}' for tag in query_tags]) + r'\n'
|
||||
opts.append(tag_str)
|
||||
package_list_str, stderr = await run_rpm('-qa', *opts, sudo=False)
|
||||
package_list_str, stderr = await run_rpm(['-qa', *opts], sudo=False)
|
||||
for package_str in package_list_str.splitlines():
|
||||
tags = package_str.split('|')
|
||||
ret.append(Package(name=tags[0], vendor=tags[1], packager=tags[2], url=tags[3]))
|
||||
|
|
@ -33,5 +32,5 @@ async def all_installed_packages() -> Iterable[Package]: # export
|
|||
|
||||
async def list_files(pkg: str) -> list[str]: # export
|
||||
opts: list[str] = []
|
||||
file_list_str, stderr = await run_rpm('-ql', pkg, *opts, sudo=False)
|
||||
file_list_str, stderr = await run_rpm(['-ql', pkg, *opts], sudo=False)
|
||||
return file_list_str.splitlines()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue