77import sys
88import click
99from rich .console import Console
10- from ...utils import is_ci
10+ from ...utils import has_running_container , is_ci , is_container_running
1111
1212logger = logging .getLogger (__name__ )
1313
@@ -36,10 +36,7 @@ def _validate_postgres_for_thingsboard_check(container_map: dict) -> bool:
3636 return False
3737
3838 postgres_container = container_map ["postgres" ]
39- return (
40- hasattr (postgres_container , "state" )
41- and postgres_container .state .status == "running"
42- )
39+ return is_container_running (postgres_container )
4340
4441
4542def _find_thingsboard_containers (docker ) -> list :
@@ -58,30 +55,6 @@ def _find_thingsboard_containers(docker) -> list:
5855 return []
5956
6057
61- def _is_container_running (container ) -> bool :
62- """Check if a single container is running.
63-
64- Args:
65- container: Container object
66-
67- Returns:
68- True if container has state and is running
69- """
70- return hasattr (container , "state" ) and container .state .status == "running"
71-
72-
73- def _has_running_container (containers : list ) -> bool :
74- """Check if any container in list is running.
75-
76- Args:
77- containers: List of container objects
78-
79- Returns:
80- True if any container is running
81- """
82- return any (_is_container_running (container ) for container in containers )
83-
84-
8558def _is_thingsboard_container_running (docker ) -> bool :
8659 """Check if ThingsBoard container is running.
8760
@@ -90,7 +63,7 @@ def _is_thingsboard_container_running(docker) -> bool:
9063 while ThingsBoard is running since ThingsBoard depends on PostgreSQL.
9164 """
9265 containers = _find_thingsboard_containers (docker )
93- return _has_running_container (containers )
66+ return has_running_container (containers )
9467
9568
9669def is_thingsboard_running () -> bool :
0 commit comments