From: Bartosz Golaszewski Date: Tue, 31 Jul 2018 12:33:40 +0000 (+0200) Subject: bindings: python: bail-out if the line was not found in gpiofind.py X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ba8ee3451632719e3aec88178cf7b41b9d2b90f6;p=qemu-gpiodev%2Flibgpiod.git bindings: python: bail-out if the line was not found in gpiofind.py Currently we're not checking if the object returned from gpiod.fine_line() is None which results in an attribute error being raised when we try to call line methods on a non-line object. Add an if and bail-out with an error code if the line with given name was not found. Signed-off-by: Bartosz Golaszewski --- diff --git a/bindings/python/examples/gpiofind.py b/bindings/python/examples/gpiofind.py index 77363f7..30b8e2b 100755 --- a/bindings/python/examples/gpiofind.py +++ b/bindings/python/examples/gpiofind.py @@ -13,5 +13,8 @@ import gpiod import sys line = gpiod.find_line(sys.argv[1]) +if line is None: + sys.exit(1) + print('{} {}'.format(line.owner().name(), line.offset())) line.owner().close()