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

pull/29446/head
Adeeb Shihadeh 2 years ago committed by GitHub
parent 3563292e65
commit 2fa09a9ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      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))

Loading…
Cancel
Save