import subprocess, sys

PASS = subprocess.run(["rclone", "obscure", "opim_ops"], capture_output=True, text=True).stdout.strip()
if not PASS:
    sys.exit("obscure failed")

for kind in ("PositionRec", "CashRecon"):
    remote = ":sftp,host=100.122.225.62,port=2025,user=hermes_ops:%s/ALTECA" % kind
    r = subprocess.run(
        ["rclone", "lsf", remote, "--sftp-pass", PASS,
         "--sftp-known-hosts-file", "none", "--sftp-shell-type", "unix"],
        capture_output=True, text=True, timeout=120,
    )
    names = [n for n in r.stdout.splitlines() if n.strip()]
    hit = [n for n in names if "20261203" in n]
    print("=== %s/ALTECA ===" % kind)
    if hit:
        for n in hit:
            print("  FOUND:", n)
    else:
        dates = sorted({n[13:21] for n in names if len(n) > 21 and n[:8] == "ALTECA_"}) or ["none"]
        print("  >> still no 20261203 file; latest tokens:", dates[-1] if dates[-1] != "none" else "none")
