36 lines
1.5 KiB
Python
Executable File
36 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python
|
|
"""ctx_wave.py <start_idx> <total> — run the farm in batches, rotating the ZTE mobile IP between batches.
|
|
|
|
Requires env for ctx_farm2: CTX_CDP, CTX_CDP_PORT, CTX_CHROME_PROF, CTX_CHROME_PROXY, CTX_PROXY, CTX_ID_PROXIES, CTX_BANK.
|
|
"""
|
|
import os, subprocess, sys, time
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
|
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
PY = sys.executable
|
|
START, TOTAL = int(sys.argv[1]), int(sys.argv[2])
|
|
BATCH = int(os.environ.get("CTX_BATCH", "4"))
|
|
ROTATE = os.environ.get("CTX_ROTATE", "1") == "1"
|
|
idx = START
|
|
done = 0
|
|
while idx < START + TOTAL:
|
|
n = min(BATCH, START + TOTAL - idx)
|
|
print("\n######## WAVE %d..%d ########" % (idx, idx + n - 1), flush=True)
|
|
env = dict(os.environ)
|
|
try:
|
|
subprocess.run([PY, os.path.join(BASE, "ctx_farm2.py"), str(idx), str(n)],
|
|
cwd=BASE, env=env, timeout=3600)
|
|
except Exception as e:
|
|
print("wave err", str(e)[:150], flush=True)
|
|
idx += n
|
|
done += n
|
|
if ROTATE and idx < START + TOTAL:
|
|
try:
|
|
sys.path.insert(0, r"regfarm")
|
|
import newapi_lib as L
|
|
print("zte_rotate:", L.zte_rotate(max_wait=150), flush=True)
|
|
except Exception as e:
|
|
print("rotate err:", type(e).__name__, str(e)[:120], flush=True)
|
|
time.sleep(20)
|
|
print("\nWAVE DONE %d accounts requested" % done, flush=True) |