mirror of
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
synced 2026-10-28 13:55:08 +03:00
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 <bartekgola@gmail.com>
21 lines
408 B
Python
Executable File
21 lines
408 B
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
#
|
|
# This file is part of libgpiod.
|
|
#
|
|
# Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
|
|
#
|
|
|
|
'''Reimplementation of the gpiofind tool in Python.'''
|
|
|
|
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()
|