-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathvideo_gridUrl.py
34 lines (26 loc) · 1.14 KB
/
video_gridUrl.py
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
#!/usr/bin/env python3
import os
def get_grid_url():
max_time = 3
se_sub_path = os.getenv('SE_SUB_PATH', '')
# If SE_SUB_PATH is "/", set it to empty string
if se_sub_path == "/":
se_sub_path = ""
# Start with default grid URL
grid_url = os.getenv('SE_NODE_GRID_URL', '')
# Check for hub/router configuration
se_hub_host = os.getenv('SE_HUB_HOST') or os.getenv('SE_ROUTER_HOST')
se_hub_port = os.getenv('SE_HUB_PORT') or os.getenv('SE_ROUTER_PORT')
if se_hub_host and se_hub_port:
grid_url = f"{os.getenv('SE_SERVER_PROTOCOL', 'http')}://{se_hub_host}:{se_hub_port}{se_sub_path}"
# Check for standalone mode
elif (os.getenv('DISPLAY_CONTAINER_NAME') and
os.getenv('SE_VIDEO_RECORD_STANDALONE') == 'true'):
display_container = os.getenv('DISPLAY_CONTAINER_NAME')
node_port = os.getenv('SE_NODE_PORT', '4444')
grid_url = f"{os.getenv('SE_SERVER_PROTOCOL', 'http')}://{display_container}:{node_port}{se_sub_path}"
# Remove trailing slash if present
grid_url = grid_url.rstrip('/')
return grid_url
if __name__ == "__main__":
print(get_grid_url())