runware autoreg: http-only signup, trial credit gates, model probe
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Runware balance: сколько trial-кредита осталось на аккаунте.
|
||||
|
||||
Ключ API баланс не показывает, поэтому логинимся паролем и читаем организации.
|
||||
|
||||
Usage:
|
||||
python rw_balance.py --email a@b.c --pw 'Rw4re!xxxx'
|
||||
python rw_balance.py --bank bank.jsonl [--limit 20]
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
|
||||
import rw_reg as R
|
||||
|
||||
|
||||
def account_credit(email, pw):
|
||||
a, err = R.auth(email, pw)
|
||||
if not a:
|
||||
return {"email": email, "error": err}
|
||||
info, orgs, err = R.credit(a["token"], a["uid"])
|
||||
return {"email": email, "orgs": len(orgs), "credit": (info or {}).get("credit"),
|
||||
"isTrial": (info or {}).get("isTrial"), "err": err}
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--email")
|
||||
ap.add_argument("--pw")
|
||||
ap.add_argument("--bank")
|
||||
ap.add_argument("--limit", type=int, default=20)
|
||||
a = ap.parse_args()
|
||||
if a.bank:
|
||||
rows = [json.loads(l) for l in open(a.bank, encoding="utf-8") if l.strip()][:a.limit]
|
||||
total = 0.0
|
||||
for r in rows:
|
||||
res = account_credit(r["email"], r["pw"])
|
||||
print(json.dumps(res, ensure_ascii=False))
|
||||
total += float(res.get("credit") or 0)
|
||||
print("total credit in sample: %.2f" % total)
|
||||
return 0
|
||||
if not (a.email and a.pw):
|
||||
raise SystemExit("need --email/--pw or --bank")
|
||||
print(json.dumps(account_credit(a.email, a.pw), ensure_ascii=False))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user