#!/usr/bin/env python3 import json, subprocess, shlex, time from pathlib import Path BASE = ["python3", "scripts/sms_activation.py"] OUT = {"ts": time.strftime("%Y-%m-%d %H:%M:%S"), "runs": []} def run(args): p = subprocess.run(BASE + args, capture_output=True, text=True) item = { "cmd": " ".join(shlex.quote(x) for x in BASE + args), "rc": p.returncode, "stdout": p.stdout.strip(), "stderr": p.stderr.strip(), } try: item["json"] = json.loads(p.stdout) if p.stdout.strip() else None except Exception: item["json"] = None OUT["runs"].append(item) return item # Provider plans chosen for likely availability and low cost plans = { "smsvn": {"country": "0", "operator": "any", "service": "tg", "max_price": "0.5"}, "5sim": {"country": "any", "operator": "any", "service": "telegram", "max_price": "0.5"}, "grizzly": {"country": "0", "operator": "any", "service": "tg", "max_price": "0.5"}, } for provider, plan in plans.items(): run(["--provider", provider, "--raw", "balance"]) run(["--provider", provider, "--raw", "discover"]) buy_args = ["--provider", provider, "--raw", "buy", "--country", plan["country"], "--service", plan["service"], "--max-price", plan["max_price"]] if provider in ("smsvn", "5sim"): buy_args += ["--operator", plan["operator"]] b = run(buy_args) data = b.get("json") or {} oid = None if isinstance(data, dict): oid = data.get("activationId") or data.get("id") # if buy failed, continue next provider if not oid: continue run(["--provider", provider, "--raw", "check", "--order-id", str(oid)]) run(["--provider", provider, "--raw", "poll", "--order-id", str(oid), "--attempts", "6", "--interval", "2", "--backoff", "1.05"]) # best-effort cleanup run(["--provider", provider, "--raw", "cancel", "--order-id", str(oid)]) Path("reports/e2e_result.json").write_text(json.dumps(OUT, ensure_ascii=False, indent=2), encoding="utf-8") print("wrote reports/e2e_result.json")