From 4d995133285dfcc447c4246c5dd2b172f5eebe11 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Mon, 2 Mar 2020 12:22:27 -0800 Subject: [PATCH] Add a warning to ros2 node info when there is more than one node with the given name Signed-off-by: Emerson Knapp --- ros2node/ros2node/verb/info.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ros2node/ros2node/verb/info.py b/ros2node/ros2node/verb/info.py index 1d538ab37..932dc838e 100644 --- a/ros2node/ros2node/verb/info.py +++ b/ros2node/ros2node/verb/info.py @@ -46,7 +46,12 @@ def add_arguments(self, parser, cli_name): def main(self, *, args): with NodeStrategy(args) as node: node_names = get_node_names(node=node, include_hidden_nodes=args.include_hidden) - if args.node_name in (n.full_name for n in node_names): + count = [n.full_name for n in node_names].count(args.node_name) + if count > 1: + print('# WARNING: There are {} nodes in the graph with this exact name "{}". ' + 'You are seeing information about only one of them.'.format( + count, args.node_name)) + if count > 0: with DirectNode(args) as node: print(args.node_name) subscribers = get_subscriber_info(