lint/ps
This commit is contained in:
parent
2663288127
commit
eb5a386e02
1 changed files with 10 additions and 4 deletions
|
@ -1,9 +1,12 @@
|
||||||
|
"""Handle processes."""
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from rwx import txt
|
from rwx import txt
|
||||||
|
|
||||||
|
|
||||||
def get_tuples_args(tuples) -> list[str]:
|
def get_tuples_args(*tuples: tuple[str]) -> list[str]:
|
||||||
|
"""Turn arguments tuples into an arguments list."""
|
||||||
args: list[str] = []
|
args: list[str] = []
|
||||||
for item in tuples:
|
for item in tuples:
|
||||||
if type(item) is tuple:
|
if type(item) is tuple:
|
||||||
|
@ -13,18 +16,21 @@ def get_tuples_args(tuples) -> list[str]:
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def run(*tuples) -> subprocess.CompletedProcess:
|
def run(*tuples: tuple[str]) -> subprocess.CompletedProcess:
|
||||||
|
"""Run from a list of arguments tuples."""
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
get_tuples_args(tuples), capture_output=False, check=True
|
get_tuples_args(tuples), capture_output=False, check=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_line(*tuples, charset: str = txt.CHARSET) -> str:
|
def run_line(*tuples: tuple[str], charset: str = txt.CHARSET) -> str:
|
||||||
|
"""Run and return output line."""
|
||||||
lines = run_lines(*get_tuples_args(tuples), charset=charset)
|
lines = run_lines(*get_tuples_args(tuples), charset=charset)
|
||||||
return lines[0]
|
return lines[0]
|
||||||
|
|
||||||
|
|
||||||
def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]:
|
def run_lines(*tuples: tuple[str], charset: str = txt.CHARSET) -> list[str]:
|
||||||
|
"""Run and return output lines."""
|
||||||
process = subprocess.run(
|
process = subprocess.run(
|
||||||
get_tuples_args(tuples), capture_output=True, check=True
|
get_tuples_args(tuples), capture_output=True, check=True
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue