Skip to content

Commit

Permalink
update print formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Aug 20, 2024
1 parent 4594e36 commit bf6bfd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
28 changes: 7 additions & 21 deletions ros2controlcli/ros2controlcli/verb/load_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@ def main(self, *, args):
controllers = list_controllers(node, args.controller_manager, 20.0).controller
if any(c.name == args.controller_name for c in controllers):
print(
bcolors.WARNING
+ f"Controller : {args.controller_name} already loaded, skipping load_controller!"
+ bcolors.ENDC
f"{bcolors.WARNING}Controller : {args.controller_name} already loaded, skipping load_controller!{bcolors.ENDC}"
)
else:
if args.param_file:
if not os.path.exists(args.param_file):
print(
bcolors.FAIL
+ f"Controller parameter file : {args.param_file} does not exist, Aborting!"
+ bcolors.ENDC
f"{bcolors.FAIL}Controller parameter file : {args.param_file} does not exist, Aborting!{bcolors.ENDC}"
)
return 1
if not os.path.isabs(args.param_file):
Expand All @@ -84,15 +80,11 @@ def main(self, *, args):
ret = load_controller(node, args.controller_manager, args.controller_name)
if not ret.ok:
print(
bcolors.FAIL
+ f"Failed loading controller {args.controller_name} check controller_manager logs"
+ bcolors.ENDC
f"{bcolors.FAIL}Failed loading controller {args.controller_name} check controller_manager logs{bcolors.ENDC}"
)
return 1
print(
bcolors.OKBLUE
+ f"Successfully loaded controller {args.controller_name}"
+ bcolors.ENDC
f"{bcolors.OKBLUE}Successfully loaded controller {args.controller_name}{bcolors.ENDC}"
)

if args.set_state:
Expand All @@ -103,9 +95,7 @@ def main(self, *, args):
)
if not response.ok:
print(
bcolors.FAIL
+ f"Error configuring controller : {args.controller_name}"
+ bcolors.ENDC
f"{bcolors.FAIL}Error configuring controller : {args.controller_name}{bcolors.ENDC}"
)
return 1

Expand All @@ -115,15 +105,11 @@ def main(self, *, args):
)
if not response.ok:
print(
bcolors.FAIL
+ f"Error activating controller : {args.controller_name}, check controller_manager logs"
+ bcolors.ENDC
f"{bcolors.FAIL}Error activating controller : {args.controller_name}, check controller_manager logs{bcolors.ENDC}"
)
return 1

print(
bcolors.OKBLUE
+ f"Successfully loaded controller {args.controller_name} into state {args.set_state}"
+ bcolors.ENDC
f"{bcolors.OKBLUE}Successfully loaded controller {args.controller_name} into state {args.set_state}{bcolors.ENDC}"
)
return 0
8 changes: 2 additions & 6 deletions ros2controlcli/ros2controlcli/verb/unload_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ def main(self, *, args):
response = unload_controller(node, args.controller_manager, args.controller_name)
if not response.ok:
print(
bcolors.FAIL
+ f"Error unloading controller {args.controller_name}, check controller_manager logs"
+ bcolors.ENDC
f"{bcolors.FAIL}Error unloading controller {args.controller_name}, check controller_manager logs{bcolors.ENDC}"
)
return 1

print(
bcolors.OKBLUE
+ f"Successfully unloaded controller {args.controller_name}"
+ bcolors.ENDC
f"{bcolors.OKBLUE}Successfully unloaded controller {args.controller_name}{bcolors.ENDC}"
)
return 0

0 comments on commit bf6bfd5

Please sign in to comment.