One-KVM/kvmd/plugins/atx/__init__.py
mofeng-git b419641251 Revert "进一步的 kvmd 国际化(汉化)支持,添加配置入口"
This reverts commit 35397c54143f3dba89bebc4e30bc09b0804b5798.
2024-11-20 12:44:59 +00:00

89 lines
3.0 KiB
Python

# ========================================================================== #
# #
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2024 Maxim Devaev <mdevaev@gmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# #
# ========================================================================== #
from typing import AsyncGenerator
from ...errors import OperationError
from ...errors import IsBusyError
from ...lanuages import Lanuages
from .. import BasePlugin
from .. import get_plugin_class
# =====
class AtxError(Exception):
pass
class AtxOperationError(OperationError, AtxError):
pass
class AtxIsBusyError(IsBusyError, AtxError):
def __init__(self) -> None:
super().__init__(Lanuages().gettext("Performing another ATX operation, please try again later"))
# =====
class BaseAtx(BasePlugin):
async def get_state(self) -> dict:
raise NotImplementedError
async def poll_state(self) -> AsyncGenerator[dict, None]:
yield {}
raise NotImplementedError
async def cleanup(self) -> None:
pass
# =====
async def power_on(self, wait: bool) -> None:
raise NotImplementedError
async def power_off(self, wait: bool) -> None:
raise NotImplementedError
async def power_off_hard(self, wait: bool) -> None:
raise NotImplementedError
async def power_reset_hard(self, wait: bool) -> None:
raise NotImplementedError
# =====
async def click_power(self, wait: bool) -> None:
raise NotImplementedError
async def click_power_long(self, wait: bool) -> None:
raise NotImplementedError
async def click_reset(self, wait: bool) -> None:
raise NotImplementedError
# =====
def get_atx_class(name: str) -> type[BaseAtx]:
return get_plugin_class("atx", name) # type: ignore