some error tolerance

This commit is contained in:
root
2024-06-28 20:10:04 -05:00
parent e17894e49c
commit 50dd0df84f

View File

@@ -15,11 +15,12 @@ def manage_containers(project: str, services: list[str]):
try: try:
project_containers = ( project_containers = (
c c
for c in client.containers.list() for c in client.containers.list(all=True)
if c.labels['com.docker.compose.project'] == project if c.labels.get('com.docker.compose.project', False)
) )
service_dict: dict[str, Container] = { service_dict: dict[str, Container] = {
c.labels['com.docker.compose.service']: c for c in project_containers service: c for c in project_containers
if (service := c.labels.get('com.docker.compose.service', False))
} }
containers: list[Container] = [service_dict[s] for s in services] containers: list[Container] = [service_dict[s] for s in services]
except Exception as e: except Exception as e: