Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | #! /usr/bin/env python3 |
| 2 | |
| 3 | import pathlib |
| 4 | import typing |
| 5 | import sys |
| 6 | |
| 7 | """ |
| 8 | List all of the machines available under the listed sub-layers of meta-arm. |
| 9 | """ |
| 10 | def list_machines(layers: typing.Sequence[str]) -> typing.Set[str]: |
| 11 | machines = set() |
| 12 | |
| 13 | # We know we're in meta-arm/scripts, so find the top-level directory |
| 14 | metaarm = pathlib.Path(__file__).resolve().parent.parent |
| 15 | if metaarm.name != "meta-arm": |
| 16 | raise Exception("Not running inside meta-arm") |
| 17 | |
| 18 | for layer in layers: |
| 19 | machines |= set(p.stem for p in (metaarm / layer / "conf" / "machine").glob("*.conf")) |
| 20 | return machines |
| 21 | |
| 22 | if __name__ == "__main__": |
| 23 | if len(sys.argv) > 1: |
| 24 | machines = list_machines(sys.argv[1:]) |
| 25 | print(" ".join(sorted(machines))) |
| 26 | sys.exit(0) |
| 27 | else: |
| 28 | print("Usage:\n$ %s [layer name ...] " % sys.argv[0]) |
| 29 | sys.exit(1) |