Skip to content
Snippets Groups Projects

force `subprocess.run` to check return code is 0

Merged Hans Fangohr requested to merge force-checking-of-error-code into linux-debian11
Files
2
@@ -89,6 +89,7 @@ def setup_log_cmd(
subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE,
check=True,
)
.stdout.decode()
.strip()
@@ -97,6 +98,7 @@ def setup_log_cmd(
subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
stdout=subprocess.PIPE,
check=True,
)
.stdout.decode()
.strip()
@@ -142,19 +144,20 @@ def create_dir_structure(mpsd_release: str, script_dir: Path) -> None:
"git",
"clone",
config_vars["spack_environments_repo"],
]
],
check=True,
)
with os_chdir("spack-environments"):
# Git fetch and checkout the release branch and git pull
# to be sure that the resulting repo is up to date
subprocess.run(["git", "fetch", "--all"])
subprocess.run(["git", "fetch", "--all"], check=True)
checkout_result = subprocess.run(["git", "checkout", mpsd_release])
if checkout_result.returncode != 0:
raise Exception(
"Release branch does not exist in spack-environment repo \n."
"Check for typos."
)
subprocess.run(["git", "pull"])
subprocess.run(["git", "pull"], check=True)
def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, List[str]]:
@@ -186,13 +189,17 @@ def get_release_info(mpsd_release: str, script_dir: Path) -> Tuple[str, str, Lis
with os_chdir("spack-environments"):
# Get the branch and commit hash of the spack-environments repo
spe_commit_hash = (
subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE)
subprocess.run(
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True
)
.stdout.decode()
.strip()
)
spe_branch = (
subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE
["git", "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE,
check=True,
)
.stdout.decode()
.strip()
@@ -331,6 +338,7 @@ def install_environment(
f"bash {spack_setup_script} {' '.join(install_flags)} {toolchain} 2>&1 "
f"| tee -a {install_log_file} ",
shell=True,
check=True,
)
Loading