mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
don't spam about stopped kvmd-fan
This commit is contained in:
parent
6dc1b758b5
commit
8775cd2286
@ -376,6 +376,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
"state_poll": Option(10.0, type=valid_float_f01),
|
"state_poll": Option(10.0, type=valid_float_f01),
|
||||||
},
|
},
|
||||||
"fan": {
|
"fan": {
|
||||||
|
"daemon": Option("kvmd-fan", type=valid_stripped_string),
|
||||||
"unix": Option("", type=valid_abs_path, if_empty="", unpack_as="unix_path"),
|
"unix": Option("", type=valid_abs_path, if_empty="", unpack_as="unix_path"),
|
||||||
"timeout": Option(5.0, type=valid_float_f01),
|
"timeout": Option(5.0, type=valid_float_f01),
|
||||||
"state_poll": Option(5.0, type=valid_float_f01),
|
"state_poll": Option(5.0, type=valid_float_f01),
|
||||||
|
|||||||
@ -34,6 +34,8 @@ from ....logging import get_logger
|
|||||||
from .... import aiotools
|
from .... import aiotools
|
||||||
from .... import htclient
|
from .... import htclient
|
||||||
|
|
||||||
|
from ..sysunit import get_service_status
|
||||||
|
|
||||||
from .base import BaseInfoSubmanager
|
from .base import BaseInfoSubmanager
|
||||||
|
|
||||||
|
|
||||||
@ -41,19 +43,22 @@ from .base import BaseInfoSubmanager
|
|||||||
class FanInfoSubmanager(BaseInfoSubmanager):
|
class FanInfoSubmanager(BaseInfoSubmanager):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
daemon: str,
|
||||||
unix_path: str,
|
unix_path: str,
|
||||||
timeout: float,
|
timeout: float,
|
||||||
state_poll: float,
|
state_poll: float,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
|
self.__daemon = daemon
|
||||||
self.__unix_path = unix_path
|
self.__unix_path = unix_path
|
||||||
self.__timeout = timeout
|
self.__timeout = timeout
|
||||||
self.__state_poll = state_poll
|
self.__state_poll = state_poll
|
||||||
|
|
||||||
async def get_state(self) -> Dict:
|
async def get_state(self) -> Dict:
|
||||||
|
monitored = await self.__get_monitored()
|
||||||
return {
|
return {
|
||||||
"monitored": bool(self.__unix_path),
|
"monitored": monitored,
|
||||||
"state": ((await self.__get_fan_state() if self.__unix_path else None)),
|
"state": ((await self.__get_fan_state() if monitored else None)),
|
||||||
}
|
}
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||||
@ -77,6 +82,13 @@ class FanInfoSubmanager(BaseInfoSubmanager):
|
|||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|
||||||
|
async def __get_monitored(self) -> bool:
|
||||||
|
if self.__unix_path:
|
||||||
|
status = await aiotools.run_async(get_service_status, self.__daemon)
|
||||||
|
if status is not None:
|
||||||
|
return (status[0] or status[1])
|
||||||
|
return False
|
||||||
|
|
||||||
async def __get_fan_state(self) -> Optional[Dict]:
|
async def __get_fan_state(self) -> Optional[Dict]:
|
||||||
try:
|
try:
|
||||||
async with self.__make_http_session() as session:
|
async with self.__make_http_session() as session:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user