-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbazaar_chronicle.py
More file actions
53 lines (40 loc) · 1.04 KB
/
bazaar_chronicle.py
File metadata and controls
53 lines (40 loc) · 1.04 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import threading
import time
import webbrowser
import urllib.request
from main import run_tracker_watch_mode
from web.app import run_web_app
APP_URL = "http://127.0.0.1:5000"
def _open_browser() -> None:
try:
webbrowser.open(APP_URL)
except Exception:
pass
def wait_for_server_and_open_browser():
for _ in range(40): # wait up to ~20 seconds
try:
urllib.request.urlopen(APP_URL)
webbrowser.open(APP_URL)
return
except Exception:
time.sleep(0.5)
# fallback if server never responded
webbrowser.open(APP_URL)
def _start_tracker_thread() -> threading.Thread:
t = threading.Thread(
target=run_tracker_watch_mode,
kwargs={
"pretty": False,
"screenshots_enabled": True,
},
daemon=True,
)
t.start()
return t
if __name__ == "__main__":
_start_tracker_thread()
threading.Thread(
target=wait_for_server_and_open_browser,
daemon=True
).start()
run_web_app()