jw.pkg.cmds.distro.backend.BackendCmd -> Backend
Rename jw.pkg.cmds.distro.backend.BackendCmd to Backend, because it's not necessarily a command, i.e. doesn't necessarily have a run() method. It's more of a distribution abstraction of the steps needed for for a specific command, the run() method itself is implemented in jw.pkg.cmds.distro.CmdXxx. This commit is the beginning of a bigger move to change the distribution backend class hierarchy. At the end of this change set, the backend command should not derive the backend classes from a base specific to the respective distribution, but from an abstract base class specific to the command run. The distribution specifics are then going to be encapsulated in another class called "Util", an instance of which is going to be provided to the backend as .util member. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
b1d4e20295
commit
2cc3b59e75
5 changed files with 9 additions and 9 deletions
20
src/python/jw/pkg/cmds/distro/backend/Backend.py
Normal file
20
src/python/jw/pkg/cmds/distro/backend/Backend.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ....lib.util import run_cmd, run_sudo
|
||||
from ..Cmd import Cmd
|
||||
|
||||
class Backend:
|
||||
|
||||
def __init__(self, parent: Cmd):
|
||||
self.__parent = parent
|
||||
|
||||
async def _sudo(self, cmd: list[str], mod_env: dict[str, str] = {}, opts: list[str]=[]):
|
||||
return await run_sudo(cmd, mod_env=mod_env, opts=opts, interactive=self.interactive)
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self.__parent
|
||||
|
||||
@property
|
||||
def interactive(self) -> bool:
|
||||
return self.__parent.interactive
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ...Cmd import Cmd
|
||||
from ..BackendCmd import BackendCmd
|
||||
from ..Backend import Backend
|
||||
|
||||
class Base(BackendCmd):
|
||||
class Base(Backend):
|
||||
|
||||
def __init__(self, parent: Cmd):
|
||||
super().__init__(parent)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ...Cmd import Cmd
|
||||
from ..BackendCmd import BackendCmd
|
||||
from ..Backend import Backend
|
||||
|
||||
class Base(BackendCmd):
|
||||
class Base(Backend):
|
||||
|
||||
def __init__(self, parent: Cmd):
|
||||
super().__init__(parent)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ...Cmd import Cmd
|
||||
from ..BackendCmd import BackendCmd
|
||||
from ..Backend import Backend
|
||||
|
||||
class Base(BackendCmd):
|
||||
class Base(Backend):
|
||||
|
||||
def __init__(self, parent: Cmd):
|
||||
super().__init__(parent)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ...Cmd import Cmd
|
||||
from ..BackendCmd import BackendCmd
|
||||
from ..Backend import Backend
|
||||
|
||||
class Base(BackendCmd):
|
||||
class Base(Backend):
|
||||
|
||||
def __init__(self, parent: Cmd):
|
||||
super().__init__(parent)
|
||||
|
|
|
|||
Loading…
Reference in a new issue