From aa36686ea45f6feef2f23746d4bc404c371e0418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 4 Sep 2023 13:47:10 +0200 Subject: [PATCH] mavsdk_tests: highlight px4 errors & reset color on gazebo output --- test/mavsdk_tests/process_helper.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/mavsdk_tests/process_helper.py b/test/mavsdk_tests/process_helper.py index 5c8701e39d..49f67978c0 100644 --- a/test/mavsdk_tests/process_helper.py +++ b/test/mavsdk_tests/process_helper.py @@ -9,6 +9,7 @@ import shutil import threading import errno from typing import Any, Dict, List, TextIO, Optional +from logger_helper import colorize, color PX4_SITL_GAZEBO_PATH = "Tools/simulation/gazebo-classic/sitl_gazebo-classic" @@ -212,6 +213,16 @@ class Px4Runner(Runner): except FileExistsError: pass + def get_output_line(self) -> Optional[str]: + line = super().get_output_line() + if line is not None: + # colorize warnings and errors + if 'ERROR' in line: + line = colorize(line, color.RED) + elif 'WARN' in line: + line = colorize(line, color.YELLOW) + return line + class GzserverRunner(Runner): def __init__(self, @@ -252,6 +263,13 @@ class GzserverRunner(Runner): .format(timeout_s)) return False + def get_output_line(self) -> Optional[str]: + line = super().get_output_line() + # Some gazebo versions don't seem to reset the color, so always add a RESET + if line is not None: + line = line + color.RESET.value + return line + class GzmodelspawnRunner(Runner): def __init__(self,