Skip to content

Commit

Permalink
tr-ws/tr-ui containers (#1089)
Browse files Browse the repository at this point in the history
* made wifi interface available

* added error handling if the ui or ws containers are started without auto-remove flag

* corrections

* corrections
  • Loading branch information
MariusBaldovin authored Jan 30, 2025
1 parent c251c99 commit 0285f49
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions framework/python/src/core/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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)
Expand All @@ -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

0 comments on commit 0285f49

Please sign in to comment.