From c95f7f4c536baa7de7cadfdafa17fc085deb6210 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 5 Mar 2026 10:37:26 -0500 Subject: [PATCH] chore: remove accidentally committed files --- t/a.cc | 58 -------------------------------------- t/cf_cli_debug.py | 67 -------------------------------------------- t/cf_cli_real.py | 30 -------------------- t/cf_exact.py | 13 --------- t/cf_hang_debug.py | 70 ---------------------------------------------- 5 files changed, 238 deletions(-) delete mode 100644 t/a.cc delete mode 100644 t/cf_cli_debug.py delete mode 100644 t/cf_cli_real.py delete mode 100644 t/cf_exact.py delete mode 100644 t/cf_hang_debug.py diff --git a/t/a.cc b/t/a.cc deleted file mode 100644 index b8f7123..0000000 --- a/t/a.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - std::cout << "change\n"; -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // }}} diff --git a/t/cf_cli_debug.py b/t/cf_cli_debug.py deleted file mode 100644 index 515df76..0000000 --- a/t/cf_cli_debug.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python3 -"""Reproduce CLI hang: go through asyncio.to_thread like the real code.""" -import asyncio -import json -import sys -from pathlib import Path - -sys.path.insert(0, ".") - -from scrapers.atcoder import _ensure_browser, _solve_turnstile -from scrapers.codeforces import BASE_URL, _wait_for_gate_reload -from scrapers.timeouts import BROWSER_SESSION_TIMEOUT - - -def _test_submit(): - from scrapling.fetchers import StealthySession - - _ensure_browser() - - cookie_cache = Path.home() / ".cache" / "cp-nvim" / "codeforces-cookies.json" - saved_cookies = [] - if cookie_cache.exists(): - try: - saved_cookies = json.loads(cookie_cache.read_text()) - except Exception: - pass - - logged_in = False - - def check_login(page): - nonlocal logged_in - logged_in = page.evaluate( - "() => Array.from(document.querySelectorAll('a'))" - ".some(a => a.textContent.includes('Logout'))" - ) - print(f"logged_in: {logged_in}", flush=True) - - def submit_action(page): - print(f"ENTERED submit_action: url={page.url}", flush=True) - - with StealthySession( - headless=True, - timeout=BROWSER_SESSION_TIMEOUT, - google_search=False, - cookies=saved_cookies, - ) as session: - print("fetch homepage...", flush=True) - session.fetch(f"{BASE_URL}/", page_action=check_login, network_idle=True) - - print("fetch submit page...", flush=True) - session.fetch( - f"{BASE_URL}/contest/1933/submit", - page_action=submit_action, - ) - print("DONE", flush=True) - - return "ok" - - -async def main(): - print("Running via asyncio.to_thread...", flush=True) - result = await asyncio.to_thread(_test_submit) - print(f"Result: {result}", flush=True) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/t/cf_cli_real.py b/t/cf_cli_real.py deleted file mode 100644 index 448dab1..0000000 --- a/t/cf_cli_real.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -"""Simulate exactly what the CLI does.""" -import asyncio -import json -import os -import sys - -sys.path.insert(0, ".") - -SOURCE = '#include \nusing namespace std;\nint main() { cout << 42; }\n' - - -async def main(): - from scrapers.codeforces import CodeforcesScraper - from scrapers.language_ids import get_language_id - - scraper = CodeforcesScraper() - credentials = json.loads(os.environ.get("CP_CREDENTIALS", "{}")) - language_id = get_language_id("codeforces", "cpp") or "89" - - print(f"source length: {len(SOURCE)}", flush=True) - print(f"credentials keys: {list(credentials.keys())}", flush=True) - print(f"language_id: {language_id}", flush=True) - - result = await scraper.submit("1933", "a", SOURCE, language_id, credentials) - print(result.model_dump_json(indent=2), flush=True) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/t/cf_exact.py b/t/cf_exact.py deleted file mode 100644 index e65bbdb..0000000 --- a/t/cf_exact.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -"""Call _submit_headless directly, no asyncio.""" -import json -import os -import sys - -sys.path.insert(0, ".") - -from scrapers.codeforces import _submit_headless - -creds = json.loads(os.environ.get("CP_CREDENTIALS", "{}")) -result = _submit_headless("1933", "a", "int main(){}", "89", creds) -print(result.model_dump_json(indent=2)) diff --git a/t/cf_hang_debug.py b/t/cf_hang_debug.py deleted file mode 100644 index 0c3ba0e..0000000 --- a/t/cf_hang_debug.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python3 -"""Pinpoint where session.fetch hangs on the submit page.""" -import json -import sys -import threading -from pathlib import Path - -sys.path.insert(0, ".") - -from scrapers.atcoder import _ensure_browser -from scrapers.codeforces import BASE_URL -from scrapers.timeouts import BROWSER_SESSION_TIMEOUT - - -def watchdog(label, timeout=20): - import time - time.sleep(timeout) - print(f"WATCHDOG: {label} timed out after {timeout}s", flush=True) - import os - os._exit(1) - - -def main(): - from scrapling.fetchers import StealthySession - - _ensure_browser() - - cookie_cache = Path.home() / ".cache" / "cp-nvim" / "codeforces-cookies.json" - saved_cookies = [] - if cookie_cache.exists(): - try: - saved_cookies = json.loads(cookie_cache.read_text()) - except Exception: - pass - - def check_login(page): - logged_in = page.evaluate( - "() => Array.from(document.querySelectorAll('a'))" - ".some(a => a.textContent.includes('Logout'))" - ) - print(f"logged_in: {logged_in}", flush=True) - - def submit_action(page): - print(f"submit_action ENTERED: url={page.url} title={page.title()}", flush=True) - - try: - with StealthySession( - headless=True, - timeout=BROWSER_SESSION_TIMEOUT, - google_search=False, - cookies=saved_cookies, - ) as session: - print("1. Homepage...", flush=True) - session.fetch(f"{BASE_URL}/", page_action=check_login, network_idle=True) - - print("2. Submit page (no network_idle, no solve_cloudflare)...", flush=True) - t = threading.Thread(target=watchdog, args=("session.fetch submit", 30), daemon=True) - t.start() - - session.fetch( - f"{BASE_URL}/contest/1933/submit", - page_action=submit_action, - ) - print("3. Done!", flush=True) - except Exception as e: - print(f"FATAL: {type(e).__name__}: {e}", flush=True) - - -if __name__ == "__main__": - main()