summaryrefslogtreecommitdiff
path: root/kvmd/apps/vnc/rfb
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-09-18 04:37:43 +0300
committerMaxim Devaev <[email protected]>2024-09-18 04:37:43 +0300
commit7a53f1445619fc471c2823e7081de8b6039b938e (patch)
tree961dd0072cc976504fe4570743d801c79512e9a6 /kvmd/apps/vnc/rfb
parent45270a09d7b5076bac96887a1e36d752882e3adf (diff)
refactoring
Diffstat (limited to 'kvmd/apps/vnc/rfb')
-rw-r--r--kvmd/apps/vnc/rfb/__init__.py8
-rw-r--r--kvmd/apps/vnc/rfb/errors.py4
-rw-r--r--kvmd/apps/vnc/rfb/stream.py24
3 files changed, 18 insertions, 18 deletions
diff --git a/kvmd/apps/vnc/rfb/__init__.py b/kvmd/apps/vnc/rfb/__init__.py
index ac4e0354..c145b4b3 100644
--- a/kvmd/apps/vnc/rfb/__init__.py
+++ b/kvmd/apps/vnc/rfb/__init__.py
@@ -120,10 +120,10 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute
except asyncio.CancelledError:
logger.info("%s [%s]: Cancelling subtask ...", self._remote, name)
raise
- except RfbConnectionError as err:
- logger.info("%s [%s]: Gone: %s", self._remote, name, err)
- except (RfbError, ssl.SSLError) as err:
- logger.error("%s [%s]: Error: %s", self._remote, name, err)
+ except RfbConnectionError as ex:
+ logger.info("%s [%s]: Gone: %s", self._remote, name, ex)
+ except (RfbError, ssl.SSLError) as ex:
+ logger.error("%s [%s]: Error: %s", self._remote, name, ex)
except Exception:
logger.exception("%s [%s]: Unhandled exception", self._remote, name)
diff --git a/kvmd/apps/vnc/rfb/errors.py b/kvmd/apps/vnc/rfb/errors.py
index 1cf68818..caa4d085 100644
--- a/kvmd/apps/vnc/rfb/errors.py
+++ b/kvmd/apps/vnc/rfb/errors.py
@@ -29,5 +29,5 @@ class RfbError(Exception):
class RfbConnectionError(RfbError):
- def __init__(self, msg: str, err: Exception) -> None:
- super().__init__(f"{msg}: {tools.efmt(err)}")
+ def __init__(self, msg: str, ex: Exception) -> None:
+ super().__init__(f"{msg}: {tools.efmt(ex)}")
diff --git a/kvmd/apps/vnc/rfb/stream.py b/kvmd/apps/vnc/rfb/stream.py
index 44998617..dc3ceb1b 100644
--- a/kvmd/apps/vnc/rfb/stream.py
+++ b/kvmd/apps/vnc/rfb/stream.py
@@ -51,22 +51,22 @@ class RfbClientStream:
else:
fmt = f">{fmt}"
return struct.unpack(fmt, await self.__reader.readexactly(struct.calcsize(fmt)))[0]
- except (ConnectionError, asyncio.IncompleteReadError) as err:
- raise RfbConnectionError(f"Can't read {msg}", err)
+ except (ConnectionError, asyncio.IncompleteReadError) as ex:
+ raise RfbConnectionError(f"Can't read {msg}", ex)
async def _read_struct(self, msg: str, fmt: str) -> tuple[int, ...]:
assert len(fmt) > 1
try:
fmt = f">{fmt}"
return struct.unpack(fmt, (await self.__reader.readexactly(struct.calcsize(fmt))))
- except (ConnectionError, asyncio.IncompleteReadError) as err:
- raise RfbConnectionError(f"Can't read {msg}", err)
+ except (ConnectionError, asyncio.IncompleteReadError) as ex:
+ raise RfbConnectionError(f"Can't read {msg}", ex)
async def _read_text(self, msg: str, length: int) -> str:
try:
return (await self.__reader.readexactly(length)).decode("utf-8", errors="ignore")
- except (ConnectionError, asyncio.IncompleteReadError) as err:
- raise RfbConnectionError(f"Can't read {msg}", err)
+ except (ConnectionError, asyncio.IncompleteReadError) as ex:
+ raise RfbConnectionError(f"Can't read {msg}", ex)
# =====
@@ -84,8 +84,8 @@ class RfbClientStream:
self.__writer.write(struct.pack(f">{fmt}", *values))
if drain:
await self.__writer.drain()
- except ConnectionError as err:
- raise RfbConnectionError(f"Can't write {msg}", err)
+ except ConnectionError as ex:
+ raise RfbConnectionError(f"Can't write {msg}", ex)
async def _write_reason(self, msg: str, text: str, drain: bool=True) -> None:
encoded = text.encode("utf-8", errors="ignore")
@@ -94,8 +94,8 @@ class RfbClientStream:
self.__writer.write(encoded)
if drain:
await self.__writer.drain()
- except ConnectionError as err:
- raise RfbConnectionError(f"Can't write {msg}", err)
+ except ConnectionError as ex:
+ raise RfbConnectionError(f"Can't write {msg}", ex)
async def _write_fb_update(self, msg: str, width: int, height: int, encoding: int, drain: bool=True) -> None:
await self._write_struct(
@@ -123,8 +123,8 @@ class RfbClientStream:
server_side=True,
ssl_handshake_timeout=ssl_timeout,
)
- except ConnectionError as err:
- raise RfbConnectionError("Can't start TLS", err)
+ except ConnectionError as ex:
+ raise RfbConnectionError("Can't start TLS", ex)
ssl_reader.set_transport(transport) # type: ignore
ssl_writer = asyncio.StreamWriter(