Skip to content

Commit

Permalink
util: agents: sysfsgpio: linting fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Bastian Krause <bst@pengutronix.de>
  • Loading branch information
Bastian-Krause authored and jluebbe committed Dec 20, 2019
1 parent f7cf8b9 commit 58b2d9e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions labgrid/util/agents/sysfsgpio.py
Expand Up @@ -9,14 +9,17 @@

class GpioDigitalOutput:
_gpio_sysfs_path_prefix = '/sys/class/gpio'
_buffered_file_access=False
_buffered_file_access = False

@staticmethod
def _assert_gpio_line_is_exported(index):
gpio_sysfs_path = os.path.join(GpioDigitalOutput._gpio_sysfs_path_prefix, 'gpio{0}'.format(index))
gpio_sysfs_path = os.path.join(GpioDigitalOutput._gpio_sysfs_path_prefix,
'gpio{0}'.format(index))
if not os.path.exists(gpio_sysfs_path):
export_sysfs_path = os.path.join(GpioDigitalOutput._gpio_sysfs_path_prefix, 'export')
with open(export_sysfs_path, mode = 'r+', buffering = GpioDigitalOutput._buffered_file_access, closefd = True) as export:
with open(export_sysfs_path, mode='r+',
buffering=GpioDigitalOutput._buffered_file_access,
closefd=True) as export:
export.write(str(index))
if not os.path.exists(gpio_sysfs_path):
raise ValueError("Device not found")
Expand All @@ -25,7 +28,8 @@ def __init__(self, **kwargs):
index = kwargs['index']
self._logger = logging.getLogger("Device: ")
GpioDigitalOutput._assert_gpio_line_is_exported(index)
gpio_sysfs_path = os.path.join(GpioDigitalOutput._gpio_sysfs_path_prefix, 'gpio{0}'.format(index))
gpio_sysfs_path = os.path.join(GpioDigitalOutput._gpio_sysfs_path_prefix,
'gpio{0}'.format(index))
gpio_sysfs_direction_path = os.path.join(gpio_sysfs_path, 'direction')
self._logger.debug("Configuring GPIO %d as output.", index)
with open(gpio_sysfs_direction_path, 'wb') as direction_fd:
Expand Down

0 comments on commit 58b2d9e

Please sign in to comment.