mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 17:34:14 +02:00
12 lines
434 B
Python
12 lines
434 B
Python
import subprocess
|
|
from typing import List
|
|
|
|
|
|
def run_cmd(cmd: str, expected_code: int = 0, ignore_return_code: bool = False) -> str:
|
|
res = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, env={'LANG': 'en'})
|
|
return res.stdout.decode() if ignore_return_code or res.returncode == expected_code else None
|
|
|
|
|
|
def stream_cmd(cmd: List[str]):
|
|
return subprocess.Popen(cmd, stdout=subprocess.PIPE, env={'LANG': 'en'}).stdout
|