Optimized code performance

This commit is contained in:
Kevin Veen-Birkenbach 2024-01-09 12:59:53 +01:00
parent 7702b17a9d
commit 2b716e5d90

View File

@ -165,18 +165,18 @@ def has_image(container,image):
"""Check if the container is using the image""" """Check if the container is using the image"""
image_info = get_image_info(container) image_info = get_image_info(container)
return image in image_info[0] return image in image_info[0]
def stop_containers(containers): def stop_containers(containers):
"""Stop a list of containers.""" """Stop a list of containers."""
for container in containers: container_list = ' '.join(containers)
print(f"Stopping container {container}...") print(f"Stopping containers {container_list}...")
execute_shell_command(f"docker stop {container}") execute_shell_command(f"docker stop {container_list}")
def start_containers(containers): def start_containers(containers):
"""Start a list of stopped containers.""" """Start a list of containers."""
for container in containers: container_list = ' '.join(containers)
print(f"Starting container {container}...") print(f"Start containers {container_list}...")
execute_shell_command(f"docker start {container}") execute_shell_command(f"docker start {container_list}")
def get_container_with_image(containers,image): def get_container_with_image(containers,image):
for container in containers: for container in containers: