mirror of https://github.com/commaai/openpilot.git
common/run: add environment variable argument (#31957)
run add environment argument
old-commit-hash: efc32c2930
This commit is contained in:
parent
ad3ae98a19
commit
ac853fc354
|
@ -1,13 +1,13 @@
|
|||
import subprocess
|
||||
|
||||
|
||||
def run_cmd(cmd: list[str], cwd=None) -> str:
|
||||
return subprocess.check_output(cmd, encoding='utf8', cwd=cwd).strip()
|
||||
def run_cmd(cmd: list[str], cwd=None, env=None) -> str:
|
||||
return subprocess.check_output(cmd, encoding='utf8', cwd=cwd, env=env).strip()
|
||||
|
||||
|
||||
def run_cmd_default(cmd: list[str], default: str = "", cwd=None) -> str:
|
||||
def run_cmd_default(cmd: list[str], default: str = "", cwd=None, env=None) -> str:
|
||||
try:
|
||||
return run_cmd(cmd, cwd=cwd)
|
||||
return run_cmd(cmd, cwd=cwd, env=env)
|
||||
except subprocess.CalledProcessError:
|
||||
return default
|
||||
|
||||
|
|
Loading…
Reference in New Issue