common/gpio: fix warning on re-export (#29457)
old-commit-hash: 2fa09a9ad7cc4d1dc47c45e12189968d42d69998
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user