32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""Fake bot for checking the Run tab. Prints the same protocol lines a real bot does (ADR-0002).
|
|
|
|
FAKE_MODE: complete | partial | stuck | crash FAKE_CPS: how many checkpoints
|
|
Never touches anything outside its own log.
|
|
"""
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import rt # noqa: E402
|
|
|
|
mode = os.environ.get("FAKE_MODE", "complete")
|
|
cps = int(os.environ.get("FAKE_CPS", "3"))
|
|
print("fake bot starting (this line stays in the log file only)")
|
|
for n in range(1, cps + 1):
|
|
rt.checkpoint(n)
|
|
rt.ui(f"Working on checkpoint {n}")
|
|
if mode == "stuck" and n == 2:
|
|
time.sleep(3600) # the Run tab must kill this
|
|
if mode == "crash" and n == 2:
|
|
raise RuntimeError("Simulated crash")
|
|
time.sleep(0.4)
|
|
rt.ui(f"Checkpoint {n} finished", "ok")
|
|
rt.checkpoint_done(n)
|
|
|
|
if mode == "partial":
|
|
rt.ui("2 rows could not be processed", "warn")
|
|
rt.summary(5, [("Row 4", "Account not found"), ("Row 5", "Timed out")])
|
|
else:
|
|
rt.summary(5)
|