Skip to content

Commit e48af3b

Browse files
KyriosGN0VietND96
andauthored
Docker: migrate video_gridUrl.sh to python (#2658)
* migrate video_gridUrl.sh to python * Fix script call --------- Signed-off-by: AvivGuiser <[email protected]> Signed-off-by: Viet Nguyen Duc <[email protected]> Co-authored-by: Viet Nguyen Duc <[email protected]>
1 parent 4c35f64 commit e48af3b

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

Diff for: Video/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN apt-get -qqy update \
2626
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
2727

2828
COPY *.conf /etc/supervisor/conf.d/
29-
COPY --chown="${SEL_UID}:${SEL_GID}" *.sh video_ready.py /opt/bin/
29+
COPY --chown="${SEL_UID}:${SEL_GID}" *.sh *.py /opt/bin/
3030

3131
USER ${SEL_UID}
3232

Diff for: Video/video.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ process_name="video.recorder"
2424
if [ "${SE_VIDEO_RECORD_STANDALONE}" = "true" ]; then
2525
JQ_SESSION_ID_QUERY=".value.nodes[]?.slots[]?.session?.sessionId"
2626
SE_NODE_PORT=${SE_NODE_PORT:-"4444"}
27-
NODE_STATUS_ENDPOINT="$(/opt/bin/video_gridUrl.sh)/status"
27+
NODE_STATUS_ENDPOINT="$(python3 /opt/bin/video_gridUrl.py)/status"
2828
else
2929
JQ_SESSION_ID_QUERY=".[]?.node?.slots | .[0]?.session?.sessionId"
3030
SE_NODE_PORT=${SE_NODE_PORT:-"5555"}

Diff for: Video/video_graphQLQuery.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SESSION_ID=$1
88
if [ -n "${SE_NODE_GRID_GRAPHQL_URL}" ]; then
99
GRAPHQL_ENDPOINT=${SE_NODE_GRID_GRAPHQL_URL}
1010
else
11-
GRAPHQL_ENDPOINT="$(/opt/bin/video_gridUrl.sh)"
11+
GRAPHQL_ENDPOINT="$(python3 /opt/bin/video_gridUrl.py)"
1212
fi
1313
if [[ -n ${GRAPHQL_ENDPOINT} ]] && [[ ! ${GRAPHQL_ENDPOINT} == */graphql ]]; then
1414
GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}/graphql"

Diff for: Video/video_gridUrl.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
import os
3+
4+
def get_grid_url():
5+
max_time = 3
6+
se_sub_path = os.getenv('SE_SUB_PATH', '')
7+
8+
# If SE_SUB_PATH is "/", set it to empty string
9+
if se_sub_path == "/":
10+
se_sub_path = ""
11+
12+
# Start with default grid URL
13+
grid_url = os.getenv('SE_NODE_GRID_URL', '')
14+
15+
# Check for hub/router configuration
16+
se_hub_host = os.getenv('SE_HUB_HOST') or os.getenv('SE_ROUTER_HOST')
17+
se_hub_port = os.getenv('SE_HUB_PORT') or os.getenv('SE_ROUTER_PORT')
18+
19+
if se_hub_host and se_hub_port:
20+
grid_url = f"{os.getenv('SE_SERVER_PROTOCOL', 'http')}://{se_hub_host}:{se_hub_port}{se_sub_path}"
21+
# Check for standalone mode
22+
elif (os.getenv('DISPLAY_CONTAINER_NAME') and
23+
os.getenv('SE_VIDEO_RECORD_STANDALONE') == 'true'):
24+
display_container = os.getenv('DISPLAY_CONTAINER_NAME')
25+
node_port = os.getenv('SE_NODE_PORT', '4444')
26+
grid_url = f"{os.getenv('SE_SERVER_PROTOCOL', 'http')}://{display_container}:{node_port}{se_sub_path}"
27+
28+
# Remove trailing slash if present
29+
grid_url = grid_url.rstrip('/')
30+
31+
return grid_url
32+
33+
if __name__ == "__main__":
34+
print(get_grid_url())

Diff for: Video/video_gridUrl.sh

-20
This file was deleted.

0 commit comments

Comments
 (0)