From 185f89a541d31cbe674d64b94ad9f4022da0af39 Mon Sep 17 00:00:00 2001 From: Fredrik Olsson Date: Wed, 7 Feb 2024 13:44:10 +0100 Subject: [PATCH] More explicit handling of response that are not "ok". More closely follows the Rust API of Zenoh. --- setup.py | 2 +- zenoh_cli.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 3132228..aa6b190 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def read(fname): setup( name="zenoh-cli", - version="0.3.2", + version="0.3.3", license="Apache License 2.0", description="CLI for Zenoh", long_description=read("README.md"), diff --git a/zenoh_cli.py b/zenoh_cli.py index f5732d5..9a3710a 100644 --- a/zenoh_cli.py +++ b/zenoh_cli.py @@ -114,10 +114,10 @@ def get( session: zenoh.Session, parser: argparse.ArgumentParser, args: argparse.Namespace ): for response in session.get(args.selector, zenoh.Queue()): - try: + if response.is_ok: reply = response.ok _print_sample_to_stdout(reply, args.line, args.decoder) - except Exception: + else: logger.error( "Received error (%s) on get(%s)", reply.err.payload.decode(), @@ -147,7 +147,7 @@ def network( graph = nx.Graph() for response in session.get("@/router/*", zenoh.Queue()): - try: + if response.is_ok: reply = response.ok data = json.loads(reply.payload) @@ -162,7 +162,7 @@ def network( graph.add_node(peer, whatami=whatami) graph.add_edge(zid, peer, protocol=link_protocols) - except Exception: + else: logger.error( "Received error (%s) on get(%s)", reply.err.payload.decode(),