From 2c848ef5f030eb5107a49191bb5dd84cc84c5447 Mon Sep 17 00:00:00 2001 From: evshary Date: Sun, 20 Oct 2019 11:47:26 +0800 Subject: [PATCH] Use NodeStrategy instead of DirectNode for showing topic list. We also need to register functions for NodeStrategy: count_publishers and count_subscribers. Signed-off-by: evshary --- ros2cli/ros2cli/daemon/__init__.py | 2 ++ ros2topic/ros2topic/verb/list.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ros2cli/ros2cli/daemon/__init__.py b/ros2cli/ros2cli/daemon/__init__.py index 50f6d57e4..3841d8cba 100644 --- a/ros2cli/ros2cli/daemon/__init__.py +++ b/ros2cli/ros2cli/daemon/__init__.py @@ -69,6 +69,8 @@ def main(*, script_name='_ros2_daemon', argv=None): _print_invoked_function_name(node.get_topic_names_and_types)) server.register_function( _print_invoked_function_name(node.get_service_names_and_types)) + server.register_function(node.count_publishers) + server.register_function(node.count_subscribers) shutdown = False diff --git a/ros2topic/ros2topic/verb/list.py b/ros2topic/ros2topic/verb/list.py index fa07816aa..b7731f891 100644 --- a/ros2topic/ros2topic/verb/list.py +++ b/ros2topic/ros2topic/verb/list.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ros2cli.node.direct import DirectNode from ros2cli.node.strategy import add_arguments +from ros2cli.node.strategy import NodeStrategy from ros2topic.api import get_topic_names_and_types from ros2topic.verb import VerbExtension @@ -51,7 +51,7 @@ def add_arguments(self, parser, cli_name): def main(self, *, args): topic_info = [] - with DirectNode(args) as node: + with NodeStrategy(args) as node: topic_names_and_types = get_topic_names_and_types( node=node, include_hidden_topics=args.include_hidden_topics)