Files
manual_slop/debug_api_hooks.py

27 lines
939 B
Python

with open("src/api_hooks.py", "r", encoding="utf-8", newline="") as f:
content = f.read()
# Add debug when receiving /api/gui
old = """elif self.path == "/api/gui":
lock = _get_app_attr(app, "_pending_gui_tasks_lock")
tasks = _get_app_attr(app, "_pending_gui_tasks")
if lock and tasks is not None:
with lock: tasks.append(data)"""
new = """elif self.path == "/api/gui":
sys.stderr.write(f"[DEBUG api_hooks] /api/gui received: {data}\\n")
sys.stderr.flush()
lock = _get_app_attr(app, "_pending_gui_tasks_lock")
tasks = _get_app_attr(app, "_pending_gui_tasks")
if lock and tasks is not None:
with lock: tasks.append(data)
sys.stderr.write(f"[DEBUG api_hooks] Added task, total: {len(tasks)}\\n")
sys.stderr.flush()"""
content = content.replace(old, new)
with open("src/api_hooks.py", "w", encoding="utf-8", newline="") as f:
f.write(content)
print("Added debug to api_hooks")