20 lines
1.3 KiB
Python
20 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""family.py — add the household's three family members through the „Család" card's endpoint (B3).
|
|
Tries each name first as the family would write it (accented), then the plain form. The box answers each new member's
|
|
password ONCE; it goes to a 0600 file per member (DooPlex moves it into sec) and is never printed."""
|
|
import os, sys
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import ctl
|
|
outdir = sys.argv[1]
|
|
for want, plain in (("Ödön", "odon"), ("Írisz", "irisz"), ("Kata", "kata")):
|
|
for name in (want, plain) if want.lower() != plain else (plain,):
|
|
code, d = ctl.form("/family/members/add", {"name": name})
|
|
pw = (d.get("data") or {}).get("password") if isinstance(d, dict) else None
|
|
shown = {k: v for k, v in (d.get("data") or {}).items() if k != "password"} if isinstance(d, dict) and isinstance(d.get("data"), dict) else d
|
|
print(f"add {name!r}: {code} {shown if code == '200' else d}" + (" [password answered once → file]" if pw else ""))
|
|
if pw:
|
|
fd = os.open(os.path.join(outdir, f"fam-{plain}"), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
|
os.write(fd, pw.encode()); os.close(fd)
|
|
break
|
|
print("members:", ctl.call("GET", "/family/members")[1])
|