Skip to content

Commit

Permalink
subprocess: capture_output=True
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jun 5, 2024
1 parent bfb37bf commit eeb6f68
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/gemini3d/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,22 @@ def git_meta(path: Path | None = None) -> dict[str, str]:
return meta

ret = subprocess.run(
[git, "-C", str(path), "--version"], stdout=subprocess.PIPE, text=True
[git, "-C", str(path), "--version"], capture_output=True, text=True
)
if ret.returncode != 0:
logging.error("Git was not available or is too old")
return meta

meta["version"] = ret.stdout.strip()

ret = subprocess.run([git, "-C", str(path), "rev-parse"])
ret = subprocess.run([git, "-C", str(path), "rev-parse"], text=True)
if ret.returncode != 0:
logging.error(f"{path} is not a Git repo.")
return meta

ret = subprocess.run(
[git, "-C", str(path), "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE,
capture_output=True,
text=True,
)
if ret.returncode != 0:
Expand All @@ -171,7 +171,7 @@ def git_meta(path: Path | None = None) -> dict[str, str]:

ret = subprocess.run(
[git, "-C", str(path), "remote", "get-url", "origin"],
stdout=subprocess.PIPE,
capture_output=True,
text=True,
)
if ret.returncode != 0:
Expand All @@ -180,12 +180,12 @@ def git_meta(path: Path | None = None) -> dict[str, str]:
meta["remote"] = ret.stdout.strip()

ret = subprocess.run(
[git, "-C", str(path), "describe", "--tags"], stdout=subprocess.PIPE, text=True
[git, "-C", str(path), "describe", "--tags"], capture_output=True, text=True
)
if ret.returncode != 0:
ret = subprocess.run(
[git, "-C", str(path), "rev-parse", "--short", "HEAD"],
stdout=subprocess.PIPE,
capture_output=True,
text=True,
)
if ret.returncode != 0:
Expand All @@ -194,7 +194,7 @@ def git_meta(path: Path | None = None) -> dict[str, str]:
meta["commit"] = ret.stdout.strip()

ret = subprocess.run(
[git, "-C", str(path), "status", "--porcelain"], stdout=subprocess.PIPE, text=True
[git, "-C", str(path), "status", "--porcelain"], capture_output=True, text=True
)
if ret.returncode != 0:
logging.error(f"{path} could not determine Git status")
Expand Down

0 comments on commit eeb6f68

Please sign in to comment.