Skip to content

Commit

Permalink
Consistent use of colors for warning and error msgs in spawner (#974)
Browse files Browse the repository at this point in the history
* Fix some error and warning log msgs to use corresponding color

* Fix pre-commit warnings
  • Loading branch information
bijoua29 authored Mar 21, 2023
1 parent 7422030 commit 7ed3786
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions controller_manager/controller_manager/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,17 @@ def main(args=None):
if not wait_for_controller_manager(
node, controller_manager_name, controller_manager_timeout
):
node.get_logger().error("Controller manager not available")
node.get_logger().error(
bcolors.FAIL + "Controller manager not available" + bcolors.ENDC
)
return 1

if is_controller_loaded(node, controller_manager_name, prefixed_controller_name):
node.get_logger().warn("Controller already loaded, skipping load_controller")
node.get_logger().warn(
bcolors.WARNING
+ "Controller already loaded, skipping load_controller"
+ bcolors.ENDC
)
else:
if controller_type:
parameter = Parameter()
Expand Down Expand Up @@ -317,15 +323,19 @@ def main(args=None):
if not args.load_only:
ret = configure_controller(node, controller_manager_name, controller_name)
if not ret.ok:
node.get_logger().error("Failed to configure controller")
node.get_logger().error(
bcolors.FAIL + "Failed to configure controller" + bcolors.ENDC
)
return 1

if not args.inactive:
ret = switch_controllers(
node, controller_manager_name, [], [controller_name], True, True, 5.0
)
if not ret.ok:
node.get_logger().error("Failed to activate controller")
node.get_logger().error(
bcolors.FAIL + "Failed to activate controller" + bcolors.ENDC
)
return 1

node.get_logger().info(
Expand All @@ -350,14 +360,18 @@ def main(args=None):
node, controller_manager_name, [controller_name], [], True, True, 5.0
)
if not ret.ok:
node.get_logger().error("Failed to deactivate controller")
node.get_logger().error(
bcolors.FAIL + "Failed to deactivate controller" + bcolors.ENDC
)
return 1

node.get_logger().info("Deactivated controller")

ret = unload_controller(node, controller_manager_name, controller_name)
if not ret.ok:
node.get_logger().error("Failed to unload controller")
node.get_logger().error(
bcolors.FAIL + "Failed to unload controller" + bcolors.ENDC
)
return 1

node.get_logger().info("Unloaded controller")
Expand Down

0 comments on commit 7ed3786

Please sign in to comment.