exec/cmd: run_cmd(): add new params: stdin, stdin_input, check asddsadsa

This commit is contained in:
InsanePrawn 2023-07-08 18:45:09 +02:00
parent 1f9682f5de
commit 686191c388
2 changed files with 27 additions and 4 deletions

View file

@ -97,6 +97,9 @@ def run_cmd(
elevation_method: Optional[ElevationMethod] = None,
stdout: Optional[FileDescriptor] = None,
stderr: Optional[FileDescriptor] = None,
stdin: Optional[FileDescriptor] = None,
stdin_input: Optional[str] = None,
check: Optional[bool] = None,
) -> Union[CompletedProcess, int]:
"execute `script` as `switch_user`, elevating and su'ing as necessary"
kwargs: dict = {}
@ -111,6 +114,10 @@ def run_cmd(
for name, fd in {'stdout': stdout, 'stderr': stderr}.items():
if fd is not None:
kwargs[name] = fd
for name, value in {'stdin': stdin, 'input': stdin_input, 'check': check}.items():
if value is not None:
kwargs[name] = value
script = flatten_shell_script(script)
if cwd:
kwargs['cwd'] = cwd