From 2fa09a9ad7cc4d1dc47c45e12189968d42d69998 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 17 Aug 2023 16:32:23 -0700 Subject: [PATCH] common/gpio: fix warning on re-export (#29457) --- common/gpio.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/gpio.py b/common/gpio.py index 5ec23bf7b1..88a9479a60 100644 --- a/common/gpio.py +++ b/common/gpio.py @@ -1,3 +1,4 @@ +import os from functools import lru_cache from typing import Optional, List @@ -26,6 +27,9 @@ def gpio_read(pin: int) -> Optional[bool]: return val def gpio_export(pin: int) -> None: + if os.path.isdir(f"/sys/class/gpio/gpio{pin}"): + return + try: with open("/sys/class/gpio/export", 'w') as f: f.write(str(pin))