30 lines
976 B
Python
30 lines
976 B
Python
path = "/opt/weval-l99/v95_full_authed_e2e.py"
|
|
with open(path) as f:
|
|
code = f.read()
|
|
|
|
old = """ resp_data = urllib.request.urlopen(req).read().decode()
|
|
try:
|
|
resp_json = json.loads(resp_data)
|
|
session_id = resp_json.get("session_id")
|
|
except Exception as e:
|
|
session_id = None
|
|
print(f"Fresh session: {session_id}")"""
|
|
|
|
new = """ try:
|
|
resp_data = urllib.request.urlopen(req, timeout=5).read().decode()
|
|
print(f"DEBUG resp_data: {resp_data!r}")
|
|
resp_json = json.loads(resp_data)
|
|
session_id = resp_json.get("session_id")
|
|
except Exception as e:
|
|
print(f"DEBUG exception: {e}")
|
|
session_id = None
|
|
print(f"Fresh session: {session_id}")
|
|
if not session_id or not isinstance(session_id, str):
|
|
print(f"ABORT: no valid session_id (got {type(session_id).__name__})")
|
|
return"""
|
|
|
|
code = code.replace(old, new)
|
|
with open(path, "w") as f:
|
|
f.write(code)
|
|
print("PATCHED v2")
|