summaryrefslogtreecommitdiff
path: root/kvmd/plugins/ugpio
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/plugins/ugpio')
-rw-r--r--kvmd/plugins/ugpio/anelpwr.py18
-rw-r--r--kvmd/plugins/ugpio/cmd.py4
-rw-r--r--kvmd/plugins/ugpio/cmdret.py4
-rw-r--r--kvmd/plugins/ugpio/extron.py4
-rw-r--r--kvmd/plugins/ugpio/ezcoo.py4
-rw-r--r--kvmd/plugins/ugpio/gpio.py18
-rw-r--r--kvmd/plugins/ugpio/hidrelay.py12
-rw-r--r--kvmd/plugins/ugpio/hue.py16
-rw-r--r--kvmd/plugins/ugpio/ipmi.py8
-rw-r--r--kvmd/plugins/ugpio/locator.py14
-rw-r--r--kvmd/plugins/ugpio/noyito.py12
-rw-r--r--kvmd/plugins/ugpio/pway.py4
-rw-r--r--kvmd/plugins/ugpio/pwm.py8
-rw-r--r--kvmd/plugins/ugpio/tesmart.py12
-rw-r--r--kvmd/plugins/ugpio/xh_hk4401.py4
15 files changed, 71 insertions, 71 deletions
diff --git a/kvmd/plugins/ugpio/anelpwr.py b/kvmd/plugins/ugpio/anelpwr.py
index a9cc432b..af83f0a2 100644
--- a/kvmd/plugins/ugpio/anelpwr.py
+++ b/kvmd/plugins/ugpio/anelpwr.py
@@ -113,13 +113,13 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
while True:
session = self.__ensure_http_session()
try:
- async with session.get(f"{self.__url}/strg.cfg") as response:
- htclient.raise_not_200(response)
- parts = (await response.text()).split(";")
+ async with session.get(f"{self.__url}/strg.cfg") as resp:
+ htclient.raise_not_200(resp)
+ parts = (await resp.text()).split(";")
for pin in self.__state:
self.__state[pin] = (parts[1 + int(pin) * 5] == "1")
- except Exception as err:
- get_logger().error("Failed ANELPWR bulk GET request: %s", tools.efmt(err))
+ except Exception as ex:
+ get_logger().error("Failed ANELPWR bulk GET request: %s", tools.efmt(ex))
self.__state = dict.fromkeys(self.__state, None)
if self.__state != prev_state:
self._notifier.notify()
@@ -143,10 +143,10 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
url=f"{self.__url}/ctrl.htm",
data=f"F{pin}={int(state)}",
headers={"Content-Type": "text/plain"},
- ) as response:
- htclient.raise_not_200(response)
- except Exception as err:
- get_logger().error("Failed ANELPWR POST request to pin %s: %s", pin, tools.efmt(err))
+ ) as resp:
+ htclient.raise_not_200(resp)
+ except Exception as ex:
+ get_logger().error("Failed ANELPWR POST request to pin %s: %s", pin, tools.efmt(ex))
raise GpioDriverOfflineError(self)
self.__update_notifier.notify()
diff --git a/kvmd/plugins/ugpio/cmd.py b/kvmd/plugins/ugpio/cmd.py
index c3392b68..b8581ce3 100644
--- a/kvmd/plugins/ugpio/cmd.py
+++ b/kvmd/plugins/ugpio/cmd.py
@@ -78,9 +78,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
proc = await aioproc.log_process(self.__cmd, logger=get_logger(0), prefix=str(self))
if proc.returncode != 0:
raise RuntimeError(f"Custom command error: retcode={proc.returncode}")
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't run custom command [ %s ]: %s",
- tools.cmdfmt(self.__cmd), tools.efmt(err))
+ tools.cmdfmt(self.__cmd), tools.efmt(ex))
raise GpioDriverOfflineError(self)
def __str__(self) -> str:
diff --git a/kvmd/plugins/ugpio/cmdret.py b/kvmd/plugins/ugpio/cmdret.py
index 0eea78f6..7080a390 100644
--- a/kvmd/plugins/ugpio/cmdret.py
+++ b/kvmd/plugins/ugpio/cmdret.py
@@ -71,9 +71,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
try:
proc = await aioproc.log_process(self.__cmd, logger=get_logger(0), prefix=str(self))
return (proc.returncode == 0)
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't run custom command [ %s ]: %s",
- tools.cmdfmt(self.__cmd), tools.efmt(err))
+ tools.cmdfmt(self.__cmd), tools.efmt(ex))
raise GpioDriverOfflineError(self)
async def write(self, pin: str, state: bool) -> None:
diff --git a/kvmd/plugins/ugpio/extron.py b/kvmd/plugins/ugpio/extron.py
index cb9fe96e..81a66c92 100644
--- a/kvmd/plugins/ugpio/extron.py
+++ b/kvmd/plugins/ugpio/extron.py
@@ -150,9 +150,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
assert channel is not None
self.__send_channel(tty, channel)
- except Exception as err:
+ except Exception as ex:
self.__channel_queue.put_nowait(None)
- if isinstance(err, serial.SerialException) and err.errno == errno.ENOENT: # pylint: disable=no-member
+ if isinstance(ex, serial.SerialException) and ex.errno == errno.ENOENT: # pylint: disable=no-member
logger.error("Missing %s serial device: %s", self, self.__device_path)
else:
logger.exception("Unexpected %s error", self)
diff --git a/kvmd/plugins/ugpio/ezcoo.py b/kvmd/plugins/ugpio/ezcoo.py
index c3502a61..d5bd8ef8 100644
--- a/kvmd/plugins/ugpio/ezcoo.py
+++ b/kvmd/plugins/ugpio/ezcoo.py
@@ -150,9 +150,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
assert channel is not None
self.__send_channel(tty, channel)
- except Exception as err:
+ except Exception as ex:
self.__channel_queue.put_nowait(None)
- if isinstance(err, serial.SerialException) and err.errno == errno.ENOENT: # pylint: disable=no-member
+ if isinstance(ex, serial.SerialException) and ex.errno == errno.ENOENT: # pylint: disable=no-member
logger.error("Missing %s serial device: %s", self, self.__device_path)
else:
logger.exception("Unexpected %s error", self)
diff --git a/kvmd/plugins/ugpio/gpio.py b/kvmd/plugins/ugpio/gpio.py
index 1ae1fbe0..6cda826b 100644
--- a/kvmd/plugins/ugpio/gpio.py
+++ b/kvmd/plugins/ugpio/gpio.py
@@ -54,7 +54,7 @@ class Plugin(BaseUserGpioDriver):
self.__output_pins: dict[int, (bool | None)] = {}
self.__reader: (aiogp.AioReader | None) = None
- self.__outputs_request: (gpiod.LineRequest | None) = None
+ self.__outputs_req: (gpiod.LineRequest | None) = None
@classmethod
def get_plugin_options(cls) -> dict:
@@ -74,7 +74,7 @@ class Plugin(BaseUserGpioDriver):
def prepare(self) -> None:
assert self.__reader is None
- assert self.__outputs_request is None
+ assert self.__outputs_req is None
self.__reader = aiogp.AioReader(
path=self.__device_path,
consumer="kvmd::gpio::inputs",
@@ -82,7 +82,7 @@ class Plugin(BaseUserGpioDriver):
notifier=self._notifier,
)
if self.__output_pins:
- self.__outputs_request = gpiod.request_lines(
+ self.__outputs_req = gpiod.request_lines(
self.__device_path,
consumer="kvmd::gpiod::outputs",
config={
@@ -99,9 +99,9 @@ class Plugin(BaseUserGpioDriver):
await self.__reader.poll()
async def cleanup(self) -> None:
- if self.__outputs_request:
+ if self.__outputs_req:
try:
- self.__outputs_request.release()
+ self.__outputs_req.release()
except Exception:
pass
@@ -110,15 +110,15 @@ class Plugin(BaseUserGpioDriver):
pin_int = int(pin)
if pin_int in self.__input_pins:
return self.__reader.get(pin_int)
- assert self.__outputs_request
+ assert self.__outputs_req
assert pin_int in self.__output_pins
- return bool(self.__outputs_request.get_value(pin_int).value)
+ return bool(self.__outputs_req.get_value(pin_int).value)
async def write(self, pin: str, state: bool) -> None:
- assert self.__outputs_request
+ assert self.__outputs_req
pin_int = int(pin)
assert pin_int in self.__output_pins
- self.__outputs_request.set_value(pin_int, gpiod.line.Value(state))
+ self.__outputs_req.set_value(pin_int, gpiod.line.Value(state))
def __str__(self) -> str:
return f"GPIO({self._instance_name})"
diff --git a/kvmd/plugins/ugpio/hidrelay.py b/kvmd/plugins/ugpio/hidrelay.py
index 894da42c..17f41e27 100644
--- a/kvmd/plugins/ugpio/hidrelay.py
+++ b/kvmd/plugins/ugpio/hidrelay.py
@@ -93,9 +93,9 @@ class Plugin(BaseUserGpioDriver):
try:
with self.__ensure_device("probing"):
pass
- except Exception as err:
+ except Exception as ex:
logger.error("Can't probe %s on %s: %s",
- self, self.__device_path, tools.efmt(err))
+ self, self.__device_path, tools.efmt(ex))
self.__reset_pins()
async def run(self) -> None:
@@ -137,9 +137,9 @@ class Plugin(BaseUserGpioDriver):
pin, state, self, self.__device_path)
try:
self.__inner_write(pin, state)
- except Exception as err:
+ except Exception as ex:
logger.error("Can't reset pin=%d of %s on %s: %s",
- pin, self, self.__device_path, tools.efmt(err))
+ pin, self, self.__device_path, tools.efmt(ex))
def __inner_read(self, pin: int) -> bool:
assert 0 <= pin <= 7
@@ -168,9 +168,9 @@ class Plugin(BaseUserGpioDriver):
get_logger(0).info("Opened %s on %s while %s", self, self.__device_path, context)
try:
yield self.__device
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Error occured on %s on %s while %s: %s",
- self, self.__device_path, context, tools.efmt(err))
+ self, self.__device_path, context, tools.efmt(ex))
self.__close_device()
raise
diff --git a/kvmd/plugins/ugpio/hue.py b/kvmd/plugins/ugpio/hue.py
index 2c0e6749..9ed9e206 100644
--- a/kvmd/plugins/ugpio/hue.py
+++ b/kvmd/plugins/ugpio/hue.py
@@ -111,13 +111,13 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
while True:
session = self.__ensure_http_session()
try:
- async with session.get(f"{self.__url}/api/{self.__token}/lights") as response:
- results = await response.json()
+ async with session.get(f"{self.__url}/api/{self.__token}/lights") as resp:
+ results = await resp.json()
for pin in self.__state:
if pin in results:
self.__state[pin] = bool(results[pin]["state"]["on"])
- except Exception as err:
- get_logger().error("Failed Hue bulk GET request: %s", tools.efmt(err))
+ except Exception as ex:
+ get_logger().error("Failed Hue bulk GET request: %s", tools.efmt(ex))
self.__state = dict.fromkeys(self.__state, None)
if self.__state != prev_state:
self._notifier.notify()
@@ -140,10 +140,10 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
async with session.put(
url=f"{self.__url}/api/{self.__token}/lights/{pin}/state",
json={"on": state},
- ) as response:
- htclient.raise_not_200(response)
- except Exception as err:
- get_logger().error("Failed Hue PUT request to pin %s: %s", pin, tools.efmt(err))
+ ) as resp:
+ htclient.raise_not_200(resp)
+ except Exception as ex:
+ get_logger().error("Failed Hue PUT request to pin %s: %s", pin, tools.efmt(ex))
raise GpioDriverOfflineError(self)
self.__update_notifier.notify()
diff --git a/kvmd/plugins/ugpio/ipmi.py b/kvmd/plugins/ugpio/ipmi.py
index 8aec6c3d..37a7a16f 100644
--- a/kvmd/plugins/ugpio/ipmi.py
+++ b/kvmd/plugins/ugpio/ipmi.py
@@ -153,9 +153,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
proc = await aioproc.log_process(**self.__make_ipmitool_kwargs(action), logger=get_logger(0), prefix=str(self))
if proc.returncode != 0:
raise RuntimeError(f"Ipmitool error: retcode={proc.returncode}")
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't send IPMI power-%s request to %s:%d: %s",
- action, self.__host, self.__port, tools.efmt(err))
+ action, self.__host, self.__port, tools.efmt(ex))
raise GpioDriverOfflineError(self)
# =====
@@ -171,9 +171,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
self.__online = True
return
raise RuntimeError(f"Invalid ipmitool response: {text}")
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't fetch IPMI power status from %s:%d: %s",
- self.__host, self.__port, tools.efmt(err))
+ self.__host, self.__port, tools.efmt(ex))
self.__power = False
self.__online = False
diff --git a/kvmd/plugins/ugpio/locator.py b/kvmd/plugins/ugpio/locator.py
index f42116a7..d5cba719 100644
--- a/kvmd/plugins/ugpio/locator.py
+++ b/kvmd/plugins/ugpio/locator.py
@@ -53,7 +53,7 @@ class Plugin(BaseUserGpioDriver):
self.__device_path = device_path
self.__tasks: dict[int, (asyncio.Task | None)] = {}
- self.__line_request: (gpiod.LineRequest | None) = None
+ self.__line_req: (gpiod.LineRequest | None) = None
@classmethod
def get_plugin_options(cls) -> dict:
@@ -74,7 +74,7 @@ class Plugin(BaseUserGpioDriver):
self.__tasks[int(pin)] = None
def prepare(self) -> None:
- self.__line_request = gpiod.request_lines(
+ self.__line_req = gpiod.request_lines(
self.__device_path,
consumer="kvmd::locator",
config={
@@ -94,9 +94,9 @@ class Plugin(BaseUserGpioDriver):
for task in tasks:
task.cancel()
await asyncio.gather(*tasks, return_exceptions=True)
- if self.__line_request:
+ if self.__line_req:
try:
- self.__line_request.release()
+ self.__line_req.release()
except Exception:
pass
@@ -115,17 +115,17 @@ class Plugin(BaseUserGpioDriver):
async def __blink(self, pin: int) -> None:
assert pin in self.__tasks
- assert self.__line_request
+ assert self.__line_req
try:
state = True
while True:
- self.__line_request.set_value(pin, gpiod.line.Value(state))
+ self.__line_req.set_value(pin, gpiod.line.Value(state))
state = (not state)
await asyncio.sleep(0.1)
except asyncio.CancelledError:
pass
finally:
- self.__line_request.set_value(pin, gpiod.line.Value(False))
+ self.__line_req.set_value(pin, gpiod.line.Value(False))
def __str__(self) -> str:
return f"Locator({self._instance_name})"
diff --git a/kvmd/plugins/ugpio/noyito.py b/kvmd/plugins/ugpio/noyito.py
index f3c04a57..7363e2d4 100644
--- a/kvmd/plugins/ugpio/noyito.py
+++ b/kvmd/plugins/ugpio/noyito.py
@@ -91,9 +91,9 @@ class Plugin(BaseUserGpioDriver):
try:
with self.__ensure_device("probing"):
pass
- except Exception as err:
+ except Exception as ex:
logger.error("Can't probe %s on %s: %s",
- self, self.__device_path, tools.efmt(err))
+ self, self.__device_path, tools.efmt(ex))
self.__reset_pins()
async def cleanup(self) -> None:
@@ -119,9 +119,9 @@ class Plugin(BaseUserGpioDriver):
pin, state, self, self.__device_path)
try:
self.__inner_write(pin, state)
- except Exception as err:
+ except Exception as ex:
logger.error("Can't reset pin=%d of %s on %s: %s",
- pin, self, self.__device_path, tools.efmt(err))
+ pin, self, self.__device_path, tools.efmt(ex))
def __inner_write(self, pin: int, state: bool) -> None:
assert 0 <= pin <= 7
@@ -144,9 +144,9 @@ class Plugin(BaseUserGpioDriver):
get_logger(0).info("Opened %s on %s while %s", self, self.__device_path, context)
try:
yield self.__device
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Error occured on %s on %s while %s: %s",
- self, self.__device_path, context, tools.efmt(err))
+ self, self.__device_path, context, tools.efmt(ex))
self.__close_device()
raise
diff --git a/kvmd/plugins/ugpio/pway.py b/kvmd/plugins/ugpio/pway.py
index 25a1f454..140cf02a 100644
--- a/kvmd/plugins/ugpio/pway.py
+++ b/kvmd/plugins/ugpio/pway.py
@@ -153,9 +153,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
assert channel is not None
self.__send_channel(tty, channel)
- except Exception as err:
+ except Exception as ex:
self.__channel_queue.put_nowait(None)
- if isinstance(err, serial.SerialException) and err.errno == errno.ENOENT: # pylint: disable=no-member
+ if isinstance(ex, serial.SerialException) and ex.errno == errno.ENOENT: # pylint: disable=no-member
logger.error("Missing %s serial device: %s", self, self.__device_path)
else:
logger.exception("Unexpected %s error", self)
diff --git a/kvmd/plugins/ugpio/pwm.py b/kvmd/plugins/ugpio/pwm.py
index 8aedb771..f202836e 100644
--- a/kvmd/plugins/ugpio/pwm.py
+++ b/kvmd/plugins/ugpio/pwm.py
@@ -94,18 +94,18 @@ class Plugin(BaseUserGpioDriver):
pwm.period_ns = self.__period
pwm.duty_cycle_ns = self.__get_duty_cycle(bool(initial))
pwm.enable()
- except Exception as err:
+ except Exception as ex:
logger.error("Can't get PWM chip %d channel %d: %s",
- self.__chip, pin, tools.efmt(err))
+ self.__chip, pin, tools.efmt(ex))
async def cleanup(self) -> None:
for (pin, pwm) in self.__pwms.items():
try:
pwm.disable()
pwm.close()
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't cleanup PWM chip %d channel %d: %s",
- self.__chip, pin, tools.efmt(err))
+ self.__chip, pin, tools.efmt(ex))
async def read(self, pin: str) -> bool:
try:
diff --git a/kvmd/plugins/ugpio/tesmart.py b/kvmd/plugins/ugpio/tesmart.py
index 5a5cd441..bb1d39e1 100644
--- a/kvmd/plugins/ugpio/tesmart.py
+++ b/kvmd/plugins/ugpio/tesmart.py
@@ -146,9 +146,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
asyncio.ensure_future(self.__reader.readexactly(6)),
timeout=self.__timeout,
))[4]
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't send command to TESmart KVM [%s]:%d: %s",
- self.__host, self.__port, tools.efmt(err))
+ self.__host, self.__port, tools.efmt(ex))
await self.__close_device()
self.__active = -1
raise GpioDriverOfflineError(self)
@@ -168,9 +168,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
asyncio.ensure_future(asyncio.open_connection(self.__host, self.__port)),
timeout=self.__timeout,
)
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't connect to TESmart KVM [%s]:%d: %s",
- self.__host, self.__port, tools.efmt(err))
+ self.__host, self.__port, tools.efmt(ex))
raise GpioDriverOfflineError(self)
async def __ensure_device_serial(self) -> None:
@@ -179,9 +179,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
serial_asyncio.open_serial_connection(url=self.__device_path, baudrate=self.__speed),
timeout=self.__timeout,
)
- except Exception as err:
+ except Exception as ex:
get_logger(0).error("Can't connect to TESmart KVM [%s]:%d: %s",
- self.__device_path, self.__speed, tools.efmt(err))
+ self.__device_path, self.__speed, tools.efmt(ex))
raise GpioDriverOfflineError(self)
async def __close_device(self) -> None:
diff --git a/kvmd/plugins/ugpio/xh_hk4401.py b/kvmd/plugins/ugpio/xh_hk4401.py
index 7e064df9..d7a47679 100644
--- a/kvmd/plugins/ugpio/xh_hk4401.py
+++ b/kvmd/plugins/ugpio/xh_hk4401.py
@@ -157,9 +157,9 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
if self.__protocol == 2:
self.__channel_queue.put_nowait(channel)
- except Exception as err:
+ except Exception as ex:
self.__channel_queue.put_nowait(None)
- if isinstance(err, serial.SerialException) and err.errno == errno.ENOENT: # pylint: disable=no-member
+ if isinstance(ex, serial.SerialException) and ex.errno == errno.ENOENT: # pylint: disable=no-member
logger.error("Missing %s serial device: %s", self, self.__device_path)
else:
logger.exception("Unexpected %s error", self)