From ff599a089323cabbea62c309956e6cc340d3fdd0 Mon Sep 17 00:00:00 2001 From: Eric Roy <49844173+royalmo@users.noreply.github.com> Date: Fri, 12 Apr 2024 00:50:06 +0200 Subject: [PATCH] [fix] iio_info.py example: pick uri automatically when there's only one Signed-off-by: Eric Roy <49844173+royalmo@users.noreply.github.com> --- bindings/python/examples/iio_info.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bindings/python/examples/iio_info.py b/bindings/python/examples/iio_info.py index 37cc25233..f51dd620d 100755 --- a/bindings/python/examples/iio_info.py +++ b/bindings/python/examples/iio_info.py @@ -31,7 +31,11 @@ def _create_context(): print("Multiple contexts found. Please select one using --uri:") for uri, description in contexts.items(): print("\t%s: %s" % (uri, description)) - sys.exit(0) + sys.exit(0) + if len(contexts) == 0: + print("No contexts found.") + sys.exit(0) + uri = list(contexts.keys())[0] return iio.Context(uri) @@ -55,7 +59,7 @@ def write_information(self): def _context_info(self): print("IIO context created: " + self.context.name) - print("Backend version: %u.%u (git tag: %s" % self.context.version) + print("Backend version: %u.%u (git tag: %s)" % self.context.version) print("Backend description string: " + self.context.description) if len(self.context.attrs) > 0: