common/gpio: fix warning on re-export (#29457)

old-commit-hash: 2fa09a9ad7cc4d1dc47c45e12189968d42d69998
This commit is contained in:
Adeeb Shihadeh
2023-08-17 16:32:23 -07:00
committed by GitHub
parent 98b3087fbb
commit 5530871c0e

View File

@@ -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))