mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 17:45:55 +02:00
jw.pkg.cmds.distro.backend.Util: Add class
Add a common base class for all jw.pkg.cmds.distro.backend.*.Util classes. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
7181849002
commit
3c8f57f636
1 changed files with 25 additions and 0 deletions
25
src/python/jw/pkg/cmds/distro/backend/Util.py
Normal file
25
src/python/jw/pkg/cmds/distro/backend/Util.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from ....lib.util import run_cmd, run_sudo
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..Cmd import Cmd
|
||||||
|
|
||||||
|
class Util:
|
||||||
|
|
||||||
|
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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue