Commit d7d378ed authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #10384 from akx/no-shell

launch.py: Don't involve shell for running Python or getting Git output
parents 1b7e7877 d9968e61
...@@ -58,7 +58,7 @@ Use --skip-python-version-check to suppress this warning. ...@@ -58,7 +58,7 @@ Use --skip-python-version-check to suppress this warning.
@lru_cache() @lru_cache()
def commit_hash(): def commit_hash():
try: try:
return subprocess.check_output(f"{git} rev-parse HEAD", encoding='utf8').strip() return subprocess.check_output([git, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip()
except Exception: except Exception:
return "<none>" return "<none>"
...@@ -66,7 +66,7 @@ def commit_hash(): ...@@ -66,7 +66,7 @@ def commit_hash():
@lru_cache() @lru_cache()
def git_tag(): def git_tag():
try: try:
return subprocess.check_output(f"{git} describe --tags", encoding='utf8').strip() return subprocess.check_output([git, "describe", "--tags"], shell=False, encoding='utf8').strip()
except Exception: except Exception:
return "<none>" return "<none>"
...@@ -125,7 +125,7 @@ def run_pip(command, desc=None, live=default_command_live): ...@@ -125,7 +125,7 @@ def run_pip(command, desc=None, live=default_command_live):
def check_run_python(code: str) -> bool: def check_run_python(code: str) -> bool:
result = subprocess.run([python, "-c", code], capture_output=True, shell=True) result = subprocess.run([python, "-c", code], capture_output=True, shell=False)
return result.returncode == 0 return result.returncode == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment