power: add gpiod support for Arch Linux
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
776e0d6c90
commit
e92da4c82c
|
@ -5,8 +5,8 @@
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
import glob
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import struct
|
import struct
|
||||||
|
@ -30,17 +30,19 @@ from typing import (
|
||||||
)
|
)
|
||||||
|
|
||||||
# Special handling for gpiod import
|
# Special handling for gpiod import
|
||||||
HAS_GPIOD = True
|
HAS_GPIOD = False
|
||||||
DIST_PATH = "/usr/lib/python3/dist-packages"
|
PKG_PATHS = glob.glob("/usr/lib/python3*/dist-packages")
|
||||||
if os.path.exists(DIST_PATH):
|
PKG_PATHS += glob.glob("/usr/lib/python3*/site-packages")
|
||||||
sys.path.insert(0, DIST_PATH)
|
for pkg_path in PKG_PATHS:
|
||||||
|
sys.path.insert(0, pkg_path)
|
||||||
try:
|
try:
|
||||||
import gpiod
|
import gpiod
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_GPIOD = False
|
|
||||||
sys.path.pop(0)
|
sys.path.pop(0)
|
||||||
else:
|
else:
|
||||||
HAS_GPIOD = False
|
HAS_GPIOD = True
|
||||||
|
sys.path.pop(0)
|
||||||
|
break
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from confighelper import ConfigHelper
|
from confighelper import ConfigHelper
|
||||||
|
|
Loading…
Reference in New Issue