mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-04-30 18:06:35 +08:00
platform info
This commit is contained in:
@@ -12,6 +12,10 @@ from .server import Server
|
||||
from . import gpio
|
||||
|
||||
|
||||
# =====
|
||||
from .server import __version__ # noqa: F401
|
||||
|
||||
|
||||
# =====
|
||||
def main() -> None:
|
||||
config = init()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
import signal
|
||||
import asyncio
|
||||
import platform
|
||||
import functools
|
||||
import json
|
||||
import time
|
||||
|
||||
@@ -26,6 +28,21 @@ from .streamer import Streamer
|
||||
from .logging import get_logger
|
||||
|
||||
|
||||
# =====
|
||||
__version__ = "0.37"
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
def _get_system_info() -> Dict[str, Dict[str, str]]:
|
||||
return {
|
||||
"version": {
|
||||
"platform": platform.platform(),
|
||||
"python": platform.python_version(),
|
||||
"kvmd": __version__,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# =====
|
||||
def _system_task(method: Callable) -> Callable:
|
||||
async def wrap(self: "Server") -> None:
|
||||
@@ -116,6 +133,8 @@ class Server: # pylint: disable=too-many-instance-attributes
|
||||
|
||||
app = aiohttp.web.Application(loop=self.__loop)
|
||||
|
||||
app.router.add_get("/info", self.__info_handler)
|
||||
|
||||
app.router.add_get("/ws", self.__ws_handler)
|
||||
|
||||
app.router.add_get("/hid", self.__hid_state_handler)
|
||||
@@ -142,6 +161,9 @@ class Server: # pylint: disable=too-many-instance-attributes
|
||||
|
||||
aiohttp.web.run_app(app, host=host, port=port, print=self.__run_app_print)
|
||||
|
||||
async def __info_handler(self, _: aiohttp.web.Request) -> aiohttp.web.WebSocketResponse:
|
||||
return _json(_get_system_info())
|
||||
|
||||
async def __ws_handler(self, request: aiohttp.web.Request) -> aiohttp.web.WebSocketResponse:
|
||||
logger = get_logger(0)
|
||||
ws = aiohttp.web.WebSocketResponse(heartbeat=self.__heartbeat)
|
||||
|
||||
Reference in New Issue
Block a user