mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-22 00:03:52 +08:00
* version * Get build metadata * two lines * channel * cwd * default to unknown * dataclass
14 lines
313 B
Python
14 lines
313 B
Python
import subprocess
|
|
|
|
|
|
def run_cmd(cmd: list[str], cwd=None) -> str:
|
|
return subprocess.check_output(cmd, encoding='utf8', cwd=cwd).strip()
|
|
|
|
|
|
def run_cmd_default(cmd: list[str], default: str = "", cwd=None) -> str:
|
|
try:
|
|
return run_cmd(cmd, cwd=cwd)
|
|
except subprocess.CalledProcessError:
|
|
return default
|
|
|