Files
ManikandanandClaude Opus 5.5 ba15a574ab Initial import: eCW Charge Validation bot and results Portal
Snapshot of the working project as of 2026-10-23 (local 2d4d4fc), one
commit with no earlier history: the tracked files were de-identified
first (synthetic claim ids and patient data only; see Context.md
section 7). Credentials, run logs, screenshots, claim reports and client
workbooks are gitignored and not included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:38:17 +05:30

70 lines
2.7 KiB
Python

"""
Open the Chrome the bot attaches to when BROWSER_CDP_URL is set.
start_ecw_chrome.bat (or: python tools\\start_ecw_chrome.py)
Not needed for a run any more (2026-10-22): with no Chrome on the port, the
bot opens it itself when the run starts, and closes it at the end. This is
for opening it by hand — to add or sign in to the Claude extension before a
run, or to keep one open across runs (the bot never closes a Chrome it did
not open).
Google Chrome, not Playwright's Chromium, started exactly as the bot starts
it (core/browser.py `start_chrome`):
* its own profile, CDP_PROFILE_DIR (default D:\\EcwChrome): Chrome refuses a
debug port on the default profile, and C: running out of space killed the
browser mid-login once (2026-10-21);
* the debug port from BROWSER_CDP_URL, on 127.0.0.1 only;
* the eCW proxy, except for claude.ai — the extension's traffic goes
direct (the Windows proxy stays off);
* the same flags as the bot's own launch (core/browser.py CHROME_ARGS).
Close this Chrome when you are done: while it is open, any program on this PC
can drive it — a browser that has been logged in to eCW — through the port.
The bot clears eCW's cookies at the start and end of every run, not the rest
of the profile.
"""
# Run standalone from the project root: python tools\start_ecw_chrome.py
import sys as _sys
from pathlib import Path as _Path
_sys.path.insert(0, str(_Path(__file__).resolve().parent.parent / "src"))
for _s in (_sys.stdout, _sys.stderr):
try:
_s.reconfigure(encoding="utf-8", errors="replace")
except Exception:
pass
import sys
from ecw_bot import settings as cfg
from ecw_bot.core.browser import (PROXY_BYPASS, cdp_ready, # noqa: F401
chrome_command, find_chrome, start_chrome)
def main() -> int:
url = cfg.BROWSER_CDP_URL or "http://127.0.0.1:9222"
problem = cfg.cdp_url_problem(url)
if problem:
print(f"[CHROME] {problem}")
return 2
if cdp_ready(url):
print(f"[CHROME] Already running at {url} — nothing to do")
return 0
if not start_chrome(url):
return 1
proxy = cfg.proxy_settings()
print(f"[CHROME] Running at {url}")
print(f"[CHROME] Profile {cfg.CDP_PROFILE_DIR}")
print(f"[CHROME] Proxy {proxy['server'] if proxy else '(none)'}"
f"{' (direct: ' + PROXY_BYPASS + ')' if proxy else ''}")
if not cfg.BROWSER_CDP_URL:
print(f"[CHROME] Note: BROWSER_CDP_URL is blank in .env, so the bot "
f"will still launch its own browser. Set BROWSER_CDP_URL={url}")
print("[CHROME] Close this Chrome when you are done with it.")
return 0
if __name__ == "__main__":
sys.exit(main())