mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 19:32:36 +08:00
mavsdk_tests: highlight px4 errors & reset color on gazebo output
This commit is contained in:
@@ -9,6 +9,7 @@ import shutil
|
|||||||
import threading
|
import threading
|
||||||
import errno
|
import errno
|
||||||
from typing import Any, Dict, List, TextIO, Optional
|
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"
|
PX4_SITL_GAZEBO_PATH = "Tools/simulation/gazebo-classic/sitl_gazebo-classic"
|
||||||
|
|
||||||
@@ -214,6 +215,16 @@ class Px4Runner(Runner):
|
|||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
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):
|
class GzserverRunner(Runner):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
@@ -254,6 +265,13 @@ class GzserverRunner(Runner):
|
|||||||
.format(timeout_s))
|
.format(timeout_s))
|
||||||
return False
|
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):
|
class GzmodelspawnRunner(Runner):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
|||||||
Reference in New Issue
Block a user