Skip to content

Commit

Permalink
Report on missing commands in update script
Browse files Browse the repository at this point in the history
So far, we simply reported that a command failed in the dev. script for
updating to the latest meta-model. However, when the command does not
exit, an exception is raised and the traceback is reported, which is
uninformative for the user.

In this patch, we report the exact command which could not be found.
  • Loading branch information
mristin committed Aug 25, 2024
1 parent c731685 commit b418f7c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions dev_scripts/update_to_aas_core_meta_codegen_and_testgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,22 @@ def _execute(
Return the non-zero exit code, or None if the exit code was zero.
"""
exit_code = subprocess.call(cmd, stdout=stdout, stderr=stderr, cwd=cwd, env=env)
cmd_joined = " ".join(cmd)

exit_code = None # type: Optional[int]
try:
exit_code = subprocess.call(cmd, stdout=stdout, stderr=stderr, cwd=cwd, env=env)
except FileNotFoundError as exception:
print(f"Failed to execute {cmd_joined}: {exception}", file=sys.stderr)
return 1

assert exit_code is not None

if exit_code != 0:
print("Failed to execute: " + " ".join(cmd), file=sys.stderr)
print(
f"Failed to execute {cmd_joined} with exit code: {exit_code}",
file=sys.stderr
)
return exit_code

return None
Expand Down

0 comments on commit b418f7c

Please sign in to comment.