-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_browser_start.py
More file actions
29 lines (23 loc) · 986 Bytes
/
patch_browser_start.py
File metadata and controls
29 lines (23 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys, re
with open('/Users/jeremy/dev/OAR-OpenAI/run_rotator_monolith.py', 'r') as f:
code = f.read()
old_start = re.search(r' # 1\. Popen Start.*?if not tab: raise RuntimeError\("Kein Tab nach Chrome-Start verfuegbar!"\)', code, re.DOTALL).group(0)
new_start = """ # Native nodriver Start (100% stable Mac OS launch)
b = await uc.start(
port=CHROME_PORT,
user_data_dir="/tmp/oar_chrome_profile",
headless=False,
browser_args=["--disable-sync", "--disable-features=ChromeSigninIntercept,EnterpriseProfileBadging"]
)
tab = None
for _ in range(15):
try:
tab = b.tabs[0]
break
except:
await asyncio.sleep(1)
if not tab: raise RuntimeError("Kein Tab nach nativem nodriver Chrome-Start verfuegbar!")"""
code = code.replace(old_start, new_start)
with open('/Users/jeremy/dev/OAR-OpenAI/run_rotator_monolith.py', 'w') as f:
f.write(code)
print("Patch applied")