From 0285f494ec24b3c2aae21f847a089db0a3398f71 Mon Sep 17 00:00:00 2001 From: Marius <86727846+MariusBaldovin@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:13:37 +0000 Subject: [PATCH] tr-ws/tr-ui containers (#1089) * made wifi interface available * added error handling if the ui or ws containers are started without auto-remove flag * corrections * corrections --- framework/python/src/core/testrun.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/framework/python/src/core/testrun.py b/framework/python/src/core/testrun.py index f4ce62c0f..428df8474 100644 --- a/framework/python/src/core/testrun.py +++ b/framework/python/src/core/testrun.py @@ -22,6 +22,8 @@ import signal import sys import time +import docker.errors + from common import logger, util, mqtt from common.device import Device from common.testreport import TestReport @@ -32,8 +34,6 @@ from net_orc import network_orchestrator as net_orc from test_orc import test_orchestrator as test_orc -from docker.errors import ImageNotFound - LOGGER = logger.get_logger('testrun') DEFAULT_CONFIG_FILE = 'local/system.json' @@ -516,7 +516,7 @@ def start_ui(self): hostname='testrun.io', detach=True, ports={'80': 8080}) - except ImageNotFound as ie: + except docker.errors.ImageNotFound as ie: LOGGER.error('An error occured whilst starting the UI. ' + 'Please investigate and try again.') LOGGER.error(ie) @@ -532,6 +532,11 @@ def _stop_ui(self): container = client.containers.get('tr-ui') if container is not None: container.kill() + # If the container has been started without auto-remove flag remove it + try: + container.remove() + except docker.errors.APIError: + pass except docker.errors.NotFound: pass @@ -552,7 +557,7 @@ def start_ws(self): '9001': 9001, '1883': 1883 }) - except ImageNotFound as ie: + except docker.errors.ImageNotFound as ie: LOGGER.error('An error occured whilst starting the websockets server. ' + 'Please investigate and try again.') LOGGER.error(ie) @@ -565,5 +570,11 @@ def _stop_ws(self): container = client.containers.get('tr-ws') if container is not None: container.kill() + # If the container has been started without auto-remove flag remove it + try: + container.remove() + except docker.errors.APIError: + pass + except docker.errors.NotFound: pass