power: improve logging when the gpiod module fails to load
Log all import errors other than ModuleNotFound errors. Add a server warning if a gpio type is configured and the gpiod module is not loaded. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
2addf845d3
commit
8e33698e23
|
@ -38,7 +38,10 @@ for pkg_path in PKG_PATHS:
|
||||||
sys.path.insert(0, pkg_path)
|
sys.path.insert(0, pkg_path)
|
||||||
try:
|
try:
|
||||||
import gpiod
|
import gpiod
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
sys.path.pop(0)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
logging.exception("Unable to load gpiod module")
|
||||||
sys.path.pop(0)
|
sys.path.pop(0)
|
||||||
else:
|
else:
|
||||||
HAS_GPIOD = True
|
HAS_GPIOD = True
|
||||||
|
@ -84,6 +87,9 @@ class PrinterPower:
|
||||||
dev = dev_class(cfg)
|
dev = dev_class(cfg)
|
||||||
if isinstance(dev, GpioDevice) or isinstance(dev, RFDevice):
|
if isinstance(dev, GpioDevice) or isinstance(dev, RFDevice):
|
||||||
if not HAS_GPIOD:
|
if not HAS_GPIOD:
|
||||||
|
self.server.add_warning(
|
||||||
|
f"Unable to load power device [{cfg.get_name()}], "
|
||||||
|
"gpiod module not loaded")
|
||||||
continue
|
continue
|
||||||
dev.configure_line(cfg, self.chip_factory)
|
dev.configure_line(cfg, self.chip_factory)
|
||||||
self.devices[dev.get_name()] = dev
|
self.devices[dev.get_name()] = dev
|
||||||
|
|
Loading…
Reference in New Issue