scripts/taler-landing: full-scan bank collector with GOA alt units
Add a host-side Python collector that lists every bank account, pages through all ledger rows, and emits stats.json with amount_alt fields (Kilo/Mega/Peta-GOA) so large ladder withdrawals fit on the landing tiles.
This commit is contained in:
parent
51785031d6
commit
25695805b4
5 changed files with 1528 additions and 0 deletions
40
scripts/taler-landing/enrich_stats_alt.py
Executable file
40
scripts/taler-landing/enrich_stats_alt.py
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Add amount_alt / amount_full fields to a landing stats.json in place."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from goa_amounts import DEFAULT_ALT, enrich_stats_tree, load_alt_from_config # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("path", help="stats.json path")
|
||||
ap.add_argument(
|
||||
"--exchange-config",
|
||||
default="https://exchange.hacktivism.ch/config",
|
||||
)
|
||||
ap.add_argument("-o", "--out", default="", help="default: overwrite path")
|
||||
args = ap.parse_args()
|
||||
p = Path(args.path)
|
||||
data = json.loads(p.read_text(encoding="utf-8"))
|
||||
if not isinstance(data, dict) or not data.get("ok"):
|
||||
print("skip: not ok stats", file=sys.stderr)
|
||||
return 0
|
||||
alt = load_alt_from_config(args.exchange_config) or dict(DEFAULT_ALT)
|
||||
enrich_stats_tree(data, alt)
|
||||
out = Path(args.out) if args.out else p
|
||||
tmp = out.with_suffix(out.suffix + f".tmp.{os.getpid()}")
|
||||
tmp.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
tmp.replace(out)
|
||||
print(f"enriched {out}", file=sys.stderr)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue