-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscovered_apps.py
More file actions
32 lines (28 loc) · 914 Bytes
/
Copy pathdiscovered_apps.py
File metadata and controls
32 lines (28 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Scan WORKING_SPACE/greaterwms/<subpkg> for apps.py and emit apps.json.
WORKING_SPACE aligns with bomiot settings.py logic.
Run before `bomiot run` (dev) or before Nuitka packaging (CI).
Usage:
python discovered_apps.py [--out apps.json]
"""
import argparse
import os
import sys
import orjson
from pathlib import Path
def discover(working_space):
apps = []
p = Path(working_space) / "greaterwms"
if not p.is_dir():
return apps
for entry in sorted(p.iterdir()):
if entry.is_dir() and (entry / "apps.py").exists():
apps.append(f"greaterwms.{entry.name}")
return apps
def main(working_space):
ap = argparse.ArgumentParser()
ap.add_argument("--out", default="apps.json")
args = ap.parse_args()
apps = discover(working_space)
out_path = Path(working_space) / args.out
out_path.write_bytes(orjson.dumps(apps, option=orjson.OPT_INDENT_2))