Skip to content

Commit

Permalink
Add a warning to ros2 node info when there is more than one node with…
Browse files Browse the repository at this point in the history
… the given name

Signed-off-by: Emerson Knapp <[email protected]>
  • Loading branch information
emersonknapp committed Mar 2, 2020
1 parent 09b1528 commit 4d99513
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ros2node/ros2node/verb/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4d99513

Please sign in to comment.