diff options
author | Dylan M. Kozicki <[email protected]> | 2022-08-16 20:02:20 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2022-08-17 04:02:20 +0300 |
commit | e0513ced475e1dd9b59c2fc747075d1255909bf6 (patch) | |
tree | 76830339418a91d2e610da4cddafcd5b4727e146 | |
parent | 61f4e35e87d5eb7c2343788a52af3e7e99756898 (diff) |
add the ability to use command exit status as a gpio state in ugpio/cmd (#112)
-rw-r--r-- | kvmd/plugins/ugpio/cmd.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/kvmd/plugins/ugpio/cmd.py b/kvmd/plugins/ugpio/cmd.py index 5233b76f..665a4334 100644 --- a/kvmd/plugins/ugpio/cmd.py +++ b/kvmd/plugins/ugpio/cmd.py @@ -63,7 +63,7 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute @classmethod def get_modes(cls) -> Set[str]: - return set([UserGpioModes.OUTPUT]) + return set([UserGpioModes.OUTPUT, UserGpioModes.INPUT]) @classmethod def get_pin_validator(cls) -> Callable[[Any], Any]: @@ -71,6 +71,13 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute async def read(self, pin: str) -> bool: _ = pin + try: + proc = await aioproc.log_process(self.__cmd, logger=get_logger(0), prefix=str(self)) + return proc.returncode == 0 + except Exception as err: + get_logger(0).error("Can't run custom command [ %s ]: %s", + tools.cmdfmt(self.__cmd), tools.efmt(err)) + raise GpioDriverOfflineError(self) return False async def write(self, pin: str, state: bool) -> None: |