#!/usr/bin/env python3 """Save the Aira credentials in $AIRA_CONFIG_DIR/aira.json (permissions 600). Run it yourself, in your own terminal: the password is typed without echo and never appears in the logs or in the shell history. Usage: cd bridge .venv/bin/python setup_creds.py """ import getpass import json import os import stat import sys from pathlib import Path BASE = Path(os.environ.get("AIRA_CONFIG_DIR") or (Path.home() / ".hermes" / "profiles" / "carlo")) TARGET = BASE / "aira.json" def main() -> int: email = input("Aira account email: ").strip() if not email: print("empty email, aborting", file=sys.stderr) return 1 password = getpass.getpass("Password (will not be shown): ") if not password: print("empty password, aborting", file=sys.stderr) return 1 TARGET.parent.mkdir(parents=True, exist_ok=True) tmp = TARGET.with_suffix(".tmp") tmp.write_text(json.dumps({"email": email, "password": password}, indent=2)) os.chmod(tmp, stat.S_IRUSR | stat.S_IWUSR) tmp.replace(TARGET) print(f"\nOK: credentials saved in {TARGET} (permissions 600)") print("Next: .venv/bin/python aira_probe.py") return 0 if __name__ == "__main__": raise SystemExit(main())