From e3391dadb5661d695fe9bbb3e735e0e18a8b59dd Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:39:25 +0000 Subject: [PATCH] Added spawner colours to `list_controllers` depending upon active or inactive (backport #1409) (#1424) --- .../ros2controlcli/verb/list_controllers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ros2controlcli/ros2controlcli/verb/list_controllers.py b/ros2controlcli/ros2controlcli/verb/list_controllers.py index d21ec7d2e1..3628ef936c 100644 --- a/ros2controlcli/ros2controlcli/verb/list_controllers.py +++ b/ros2controlcli/ros2controlcli/verb/list_controllers.py @@ -13,6 +13,7 @@ # limitations under the License. from controller_manager import list_controllers +from controller_manager.spawner import bcolors from ros2cli.node.direct import add_arguments from ros2cli.node.strategy import NodeStrategy @@ -22,7 +23,15 @@ def print_controller_state(c, args): - print(f'{c.name:20s}[{c.type:20s}] {c.state:10s}') + state_color = "" + if c.state == "active": + state_color = bcolors.OKGREEN + elif c.state == "inactive": + state_color = bcolors.OKCYAN + elif c.state == "unconfigured": + state_color = bcolors.WARNING + + print(f"{c.name:20s}[{c.type:20s}] {state_color}{c.state:10s}{bcolors.ENDC}") if args.claimed_interfaces or args.verbose: print('\tclaimed interfaces:') for claimed_interface in c.claimed_interfaces: