diff options
author | Devaev Maxim <[email protected]> | 2020-10-13 14:55:08 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-10-13 14:55:08 +0300 |
commit | 6420bc4533490af85a33d026c120d28a7f55a044 (patch) | |
tree | 6b787e07eef6d5de3a2b6058d70615eabb0a97c0 /kvmd/apps | |
parent | c6524fc7ac3a271a91fef994a9a9529940337596 (diff) |
mypy again
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/info/hw.py | 9 | ||||
-rw-r--r-- | kvmd/apps/vnc/vncauth.py | 7 |
2 files changed, 6 insertions, 10 deletions
diff --git a/kvmd/apps/kvmd/info/hw.py b/kvmd/apps/kvmd/info/hw.py index e34ace5b..57a8521d 100644 --- a/kvmd/apps/kvmd/info/hw.py +++ b/kvmd/apps/kvmd/info/hw.py @@ -29,11 +29,10 @@ from typing import AsyncGenerator from typing import TypeVar from typing import Optional -import aiofiles - from ....logging import get_logger from .... import env +from .... import aiofs from .... import aioproc from .base import BaseInfoSubmanager @@ -89,8 +88,7 @@ class HwInfoSubmanager(BaseInfoSubmanager): async def __get_dt_model(self) -> Optional[str]: model_path = f"{env.PROCFS_PREFIX}/proc/device-tree/model" try: - async with aiofiles.open(model_path) as model_file: - return (await model_file.read()).strip(" \t\r\n\0") + return (await aiofs.read(model_path)).strip(" \t\r\n\0") except Exception as err: get_logger(0).error("Can't read DT model from %s: %s", model_path, err) return None @@ -98,8 +96,7 @@ class HwInfoSubmanager(BaseInfoSubmanager): async def __get_cpu_temp(self) -> Optional[float]: temp_path = f"{env.SYSFS_PREFIX}/sys/class/thermal/thermal_zone0/temp" try: - async with aiofiles.open(temp_path) as temp_file: - return int((await temp_file.read()).strip()) / 1000 + return int((await aiofs.read(temp_path)).strip()) / 1000 except Exception as err: get_logger(0).error("Can't read CPU temp from %s: %s", temp_path, err) return None diff --git a/kvmd/apps/vnc/vncauth.py b/kvmd/apps/vnc/vncauth.py index 06420ee0..b8283cca 100644 --- a/kvmd/apps/vnc/vncauth.py +++ b/kvmd/apps/vnc/vncauth.py @@ -25,10 +25,10 @@ import dataclasses from typing import Tuple from typing import Dict -import aiofiles - from ...logging import get_logger +from ... import aiofs + # ===== class VncAuthError(Exception): @@ -64,8 +64,7 @@ class VncAuthManager: return ({}, (not self.__enabled)) async def __inner_read_credentials(self) -> Dict[str, VncAuthKvmdCredentials]: - async with aiofiles.open(self.__path) as vc_file: - lines = (await vc_file.read()).split("\n") + lines = (await aiofs.read(self.__path)).split("\n") credentials: Dict[str, VncAuthKvmdCredentials] = {} for (lineno, line) in enumerate(lines): |