Skip to content

Commit

Permalink
Fix parser bug when unrecognized argument (#241)
Browse files Browse the repository at this point in the history
* Fix parser help error

* Fix visualize.py formatting
  • Loading branch information
thomas-bc authored Feb 7, 2025
1 parent 0404b28 commit f3d7b85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/fprime/fpp/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,26 @@ def run_fprime_visualize(
f"Unable to write to {viz_cache_base.resolve()}. Use --working-dir to set a different location."
)
for layout_txt in layout_txt_file_match:
print(f"Generated layout TXT file: {layout_txt.resolve()}")
print(f"Generated layout TXT file: {layout_txt.resolve()}")
connection_graph_json = viz_cache / f"{layout_txt.stem}.json"
# Execute: fpl-layout < ConnectionGraph.txt > ConnectionGraph.json
with open(connection_graph_json.resolve(), "w") as json_file:
with open(layout_txt.resolve(), "r") as txt_file:
txt_contents = txt_file.read()
topology_connections += txt_contents
subprocess.run(
["fpl-layout"], stdout=json_file, input=txt_contents.encode(), check=True
["fpl-layout"],
stdout=json_file,
input=txt_contents.encode(),
check=True,
)
# Generate layout JSON for entire topology (all connections graphs in one layout)
with open(topology_json.resolve(), "w") as json_file:
subprocess.run(
["fpl-layout"], stdout=json_file, input=topology_connections.encode(), check=True
["fpl-layout"],
stdout=json_file,
input=topology_connections.encode(),
check=True,
)
source_dirs.append(viz_cache)
source_resolved = [str(source.resolve()) for source in source_dirs]
Expand Down
6 changes: 5 additions & 1 deletion src/fprime/util/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,11 @@ def parse_args(args):
cmake_args, make_args = validate(parsed, unknown)
except ArgValidationException as exc:
print(f"[ERROR] {exc}", end="\n\n")
parsers.get(parsed.command, (parser,))[0].print_usage()
selected_parser = parsers.get(parsed.command, parser)
if type(selected_parser) is tuple:
selected_parser[0].print_usage()
else:
selected_parser.print_usage()
sys.exit(1)
return parsed, cmake_args, make_args, parser, runners

Expand Down

0 comments on commit f3d7b85

Please sign in to comment.