mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-28 13:55:24 +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
|
|
@ -3,7 +3,7 @@
|
|||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ....lib.util import run_cmd, run_sudo
|
||||
from ....lib.util import run_sudo
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..Cmd import Cmd
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ....lib.util import run_cmd, run_sudo
|
||||
from ....lib.util import run_sudo
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..Cmd import Cmd
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ class Delete(Base):
|
|||
super().__init__(parent)
|
||||
|
||||
async def run(self, args: Namespace):
|
||||
return await self.util.rpm('-e', *args.packages, sudo=True)
|
||||
return await self.util.rpm(['-e', *args.packages], sudo=True)
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ class Dup(Base):
|
|||
super().__init__(parent)
|
||||
|
||||
async def run(self, args: Namespace):
|
||||
return await self.util.zypper('dup', '--force-resolution', '--auto-agree-with-licenses')
|
||||
return await self.util.zypper(['dup', '--force-resolution', '--auto-agree-with-licenses'])
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ class Install(Base):
|
|||
super().__init__(parent)
|
||||
|
||||
async def run(self, args: Namespace):
|
||||
return await self.util.zypper('install', *args.packages)
|
||||
return await self.util.zypper(['install', *args.packages])
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ class Refresh(Base):
|
|||
super().__init__(parent)
|
||||
|
||||
async def run(self, args: Namespace):
|
||||
return await self.util.zypper('refresh')
|
||||
return await self.util.zypper(['refresh'])
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Util(Base):
|
|||
def __init__(self, parent: Cmd):
|
||||
super().__init__(parent)
|
||||
|
||||
async def zypper(self, *args):
|
||||
async def zypper(self, args: list[str]):
|
||||
cmd = ['/usr/bin/zypper']
|
||||
if not self.interactive:
|
||||
cmd.extend(['--non-interactive', '--gpg-auto-import-keys', '--no-gpg-checks'])
|
||||
|
|
@ -18,5 +18,5 @@ class Util(Base):
|
|||
# Run sudo --login in case /etc/profile modifies ZYPP_CONF
|
||||
return await self._sudo(cmd, opts=['--login'])
|
||||
|
||||
async def rpm(self, *args, sudo=False):
|
||||
return await run_rpm(*args, sudo=sudo)
|
||||
async def rpm(self, args: list[str], sudo=False):
|
||||
return await run_rpm(args, sudo=sudo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue