"""Read the four drill apps' state through the product (GET /api/stacks/, the app page badges hu+en).""" import json, sys, os import walk as w w.login(); w.sync_rescan() out = {} for a in ["wishlist", "navidrome", "romm", "vikunja"]: st = w.stack(a) out[a] = {"state": st.get("state"), "pinned": (st.get("app_config") or {}).get("pinned_images"), "installed": {k: v.get("ref") for k, v in ((st.get("app_config") or {}).get("installed_images") or {}).items()}, "catalog": st.get("catalog_images"), "steps_left": st.get("ladder_steps_left"), "failed_step": (st.get("app_config") or {}).get("failed_update_step"), "last_auto_update": (st.get("app_config") or {}).get("last_auto_update"), "badges": w.badges(a)} print(a, out[a]["pinned"], "steps_left", out[a]["steps_left"], out[a]["badges"]["en"][:1]) json.dump(out, open(sys.argv[1], "w"), indent=2, ensure_ascii=False)