mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 08:39:59 +08:00
UPDATE WEB UI
This commit is contained in:
+34
-27
@@ -1,27 +1,31 @@
|
||||
from fastapi import APIRouter
|
||||
from pydantic.error_wrappers import ValidationError
|
||||
|
||||
from services.log import logger
|
||||
from utils.manager import group_manager
|
||||
from utils.utils import get_bot
|
||||
|
||||
from ..auth import Depends, User, token_to_user
|
||||
from ..config import *
|
||||
from ..models.model import Group, GroupResult, Result, Task
|
||||
from ..models.params import UpdateGroup
|
||||
from ..utils import authentication
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/group", dependencies=[token_to_user()])
|
||||
@router.get("/get_group", dependencies=[authentication()])
|
||||
async def _() -> Result:
|
||||
"""
|
||||
获取群信息
|
||||
"""
|
||||
group_list_result = []
|
||||
group_info = {}
|
||||
if bot := get_bot():
|
||||
group_list = await bot.get_group_list()
|
||||
for g in group_list:
|
||||
group_info[g["group_id"]] = Group(**g)
|
||||
group_data = group_manager.get_data()
|
||||
for group_id in group_data.group_manager:
|
||||
try:
|
||||
try:
|
||||
group_info = {}
|
||||
if bot := get_bot():
|
||||
group_list = await bot.get_group_list()
|
||||
for g in group_list:
|
||||
group_info[g["group_id"]] = Group(**g)
|
||||
group_data = group_manager.get_data()
|
||||
for group_id in group_data.group_manager:
|
||||
task_list = []
|
||||
data = group_manager[group_id].dict()
|
||||
for tn, status in data["group_task_status"].items():
|
||||
@@ -39,24 +43,27 @@ async def _() -> Result:
|
||||
data["group"] = x
|
||||
else:
|
||||
continue
|
||||
try:
|
||||
group_list_result.append(GroupResult(**data))
|
||||
except ValidationError:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"WEB_UI /webui/group 发生错误 {type(e)}:{e}")
|
||||
return Result(code=200, data=group_list_result)
|
||||
group_list_result.append(GroupResult(**data))
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/get_group", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
return Result.ok(group_list_result, "拿到了新鲜出炉的数据!")
|
||||
|
||||
|
||||
@router.post("/group", dependencies=[token_to_user()])
|
||||
async def _(group: GroupResult) -> Result:
|
||||
@router.post("/update_group", dependencies=[authentication()])
|
||||
async def _(group: UpdateGroup) -> Result:
|
||||
"""
|
||||
修改群信息
|
||||
"""
|
||||
group_id = group.group.group_id
|
||||
group_manager.set_group_level(group_id, group.level)
|
||||
if group.status:
|
||||
group_manager.turn_on_group_bot_status(group_id)
|
||||
else:
|
||||
group_manager.shutdown_group_bot_status(group_id)
|
||||
return Result(data="修改成功!")
|
||||
try:
|
||||
group_id = group.group_id
|
||||
group_manager.set_group_level(group_id, group.level)
|
||||
if group.status:
|
||||
group_manager.turn_on_group_bot_status(group_id)
|
||||
else:
|
||||
group_manager.shutdown_group_bot_status(group_id)
|
||||
group_manager.save()
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/get_group", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
return Result.ok(info="已完成记录!")
|
||||
|
||||
+94
-155
@@ -1,176 +1,115 @@
|
||||
from pydantic import ValidationError
|
||||
from typing import Optional
|
||||
|
||||
import cattrs
|
||||
from fastapi import APIRouter
|
||||
|
||||
from configs.config import Config
|
||||
from services.log import logger
|
||||
from utils.manager import (
|
||||
plugins2block_manager,
|
||||
plugins2cd_manager,
|
||||
plugins2count_manager,
|
||||
plugins2settings_manager,
|
||||
plugins_manager,
|
||||
)
|
||||
from utils.utils import get_matchers
|
||||
from utils.manager import plugin_data_manager, plugins2settings_manager, plugins_manager
|
||||
from utils.manager.models import PluginData, PluginType
|
||||
|
||||
from ..auth import Depends, User, token_to_user
|
||||
from ..config import *
|
||||
from ..models.model import Plugin, PluginConfig, Result
|
||||
from ..models.params import UpdateConfig, UpdatePlugin
|
||||
from ..utils import authentication
|
||||
|
||||
plugin_name_list = None
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/plugins", dependencies=[token_to_user()])
|
||||
def _(type_: Optional[str]) -> Result:
|
||||
@router.get("/get_plugins", dependencies=[authentication()])
|
||||
def _(
|
||||
plugin_type: PluginType,
|
||||
) -> Result:
|
||||
"""
|
||||
获取插件列表
|
||||
:param type_: 类型 normal, superuser, hidden, admin
|
||||
:param plugin_type: 类型 normal, superuser, hidden, admin
|
||||
"""
|
||||
global plugin_name_list
|
||||
if not plugin_name_list:
|
||||
plugin_name_list = [x.plugin_name for x in get_matchers(True)]
|
||||
plugin_list = []
|
||||
plugin_data = plugins_manager.get_data()
|
||||
for model in plugin_data:
|
||||
if model in plugin_name_list:
|
||||
try:
|
||||
data = plugin_data.get(model)
|
||||
# data.model = model
|
||||
plugin_name = data.plugin_name
|
||||
if (
|
||||
(type_ == "hidden" and "[hidden]" not in plugin_name.lower())
|
||||
or (type_ == "admin" and "[admin]" not in plugin_name.lower())
|
||||
or (
|
||||
type_ == "superuser"
|
||||
and "[superuser]" not in plugin_name.lower()
|
||||
try:
|
||||
plugin_list = []
|
||||
for module in plugin_data_manager.keys():
|
||||
plugin_data: Optional[PluginData] = plugin_data_manager[module]
|
||||
if plugin_data and plugin_data.plugin_type == plugin_type:
|
||||
plugin_config = None
|
||||
if plugin_data.plugin_configs:
|
||||
plugin_config = {}
|
||||
for key in plugin_data.plugin_configs:
|
||||
plugin_config[key] = PluginConfig(
|
||||
key=key,
|
||||
module=module,
|
||||
has_type=bool(plugin_data.plugin_configs[key].type),
|
||||
**plugin_data.plugin_configs[key].dict(),
|
||||
)
|
||||
plugin_list.append(
|
||||
Plugin(
|
||||
model=module,
|
||||
plugin_settings=plugin_data.plugin_setting,
|
||||
plugin_manager=plugin_data.plugin_status,
|
||||
plugin_config=plugin_config,
|
||||
cd_limit=plugin_data.plugin_cd,
|
||||
block_limit=plugin_data.plugin_block,
|
||||
count_limit=plugin_data.plugin_count,
|
||||
)
|
||||
):
|
||||
continue
|
||||
if type_ == "normal" and (
|
||||
"[hidden]" in plugin_name.lower()
|
||||
or "[admin]" in plugin_name.lower()
|
||||
or "[superuser]" in plugin_name.lower()
|
||||
):
|
||||
continue
|
||||
data = {"model": model}
|
||||
if x := plugin_data.get(model):
|
||||
if not x.status and x.block_type in [
|
||||
"group",
|
||||
"private",
|
||||
"all",
|
||||
]:
|
||||
x.block_type = (
|
||||
"群聊"
|
||||
if x.block_type == "group"
|
||||
else "私聊"
|
||||
if x.block_type == "private"
|
||||
else "全部"
|
||||
)
|
||||
data["plugin_manager"] = PluginManager(**x.dict())
|
||||
if x := plugins2settings_manager.get(model):
|
||||
if x.cmd and isinstance(x.cmd, list):
|
||||
x.cmd = ",".join(x.cmd)
|
||||
data["plugin_settings"] = PluginSettings(**x.dict())
|
||||
if x := plugins2cd_manager.get(model):
|
||||
data["cd_limit"] = CdLimit(**x.dict())
|
||||
if x := plugins2block_manager.get(model):
|
||||
data["block_limit"] = BlockLimit(**x.dict())
|
||||
if x := plugins2count_manager.get(model):
|
||||
data["count_limit"] = CountLimit(**x.dict())
|
||||
if x := Config.get(model):
|
||||
id_ = 0
|
||||
tmp = []
|
||||
for key in x.keys():
|
||||
tmp.append(
|
||||
PluginConfig(
|
||||
**{
|
||||
"key": key,
|
||||
"help_": x[key].get("help"),
|
||||
"id": id_,
|
||||
**x[key],
|
||||
}
|
||||
)
|
||||
)
|
||||
id_ += 1
|
||||
data["plugin_config"] = tmp
|
||||
plugin_list.append(Plugin(**data))
|
||||
except (AttributeError, ValidationError) as e:
|
||||
logger.error(
|
||||
f"WEB_UI GET /webui/plugins model:{model} 发生错误 {type(e)}:{e}"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"WEB_UI GET /webui/plugins model:{model} 发生错误 {type(e)}:{e}"
|
||||
)
|
||||
return Result(
|
||||
code=500,
|
||||
data=f"WEB_UI GET /webui/plugins model:{model} 发生错误 {type(e)}:{e}",
|
||||
)
|
||||
return Result(code=200, data=plugin_list)
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/get_plugins", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
return Result.ok(plugin_list, "拿到了新鲜出炉的数据!")
|
||||
|
||||
|
||||
@router.post("/plugins", dependencies=[token_to_user()])
|
||||
def _(plugin: Plugin, user: User = Depends(token_to_user)) -> Result:
|
||||
@router.post("/update_plugins", dependencies=[authentication()])
|
||||
def _(plugin: UpdatePlugin) -> Result:
|
||||
"""
|
||||
修改插件信息
|
||||
:param plugin: 插件内容
|
||||
"""
|
||||
try:
|
||||
if plugin.plugin_config:
|
||||
for c in plugin.plugin_config:
|
||||
if not c.value:
|
||||
Config.set_config(plugin.model, c.key, None)
|
||||
continue
|
||||
if str(c.value).lower() in ["true", "false"] and (
|
||||
c.default_value is None or isinstance(c.default_value, bool)
|
||||
):
|
||||
c.value = str(c.value).lower() == "true"
|
||||
elif isinstance(
|
||||
Config.get_config(plugin.model, c.key, c.value), int
|
||||
) or isinstance(c.default_value, int):
|
||||
c.value = int(c.value)
|
||||
elif isinstance(
|
||||
Config.get_config(plugin.model, c.key, c.value), float
|
||||
) or isinstance(c.default_value, float):
|
||||
c.value = float(c.value)
|
||||
elif isinstance(c.value, str) and (
|
||||
isinstance(
|
||||
Config.get_config(plugin.model, c.key, c.value), (list, tuple)
|
||||
)
|
||||
or isinstance(c.default_value, (list, tuple))
|
||||
):
|
||||
default_value = Config.get_config(plugin.model, c.key, c.value)
|
||||
c.value = c.value.split(",")
|
||||
if default_value and isinstance(default_value[0], int):
|
||||
c.value = [int(x) for x in c.value]
|
||||
elif default_value and isinstance(default_value[0], float):
|
||||
c.value = [float(x) for x in c.value]
|
||||
elif default_value and isinstance(default_value[0], bool):
|
||||
temp = []
|
||||
for x in c.value:
|
||||
temp.append(x.lower() == "true")
|
||||
c.value = temp
|
||||
Config.set_config(plugin.model, c.key, c.value)
|
||||
Config.save(None, True)
|
||||
else:
|
||||
if plugin.plugin_settings:
|
||||
for key, value in plugin.plugin_settings:
|
||||
if key == "cmd":
|
||||
value = value.split(",")
|
||||
setattr(plugins2settings_manager[plugin.model], key, value)
|
||||
if plugin.plugin_manager:
|
||||
for key, value in plugin.plugin_manager:
|
||||
setattr(plugins_manager[plugin.model], key, value)
|
||||
module = plugin.module
|
||||
if p2s := plugins2settings_manager.get(module):
|
||||
p2s.default_status = plugin.default_status
|
||||
p2s.limit_superuser = plugin.limit_superuser
|
||||
p2s.cost_gold = plugin.cost_gold
|
||||
p2s.cmd = plugin.cmd
|
||||
p2s.level = plugin.group_level
|
||||
if pd := plugin_data_manager.get(module):
|
||||
menu_lin = None
|
||||
if len(pd.menu_type) > 1:
|
||||
menu_lin = pd.menu_type[1]
|
||||
if menu_lin is not None:
|
||||
pd.menu_type = (plugin.menu_type, menu_lin)
|
||||
else:
|
||||
pd.menu_type = (plugin.menu_type,)
|
||||
if pm := plugins_manager.get(module):
|
||||
if plugin.block_type:
|
||||
pm.block_type = plugin.block_type
|
||||
pm.status = False
|
||||
else:
|
||||
pm.block_type = None
|
||||
pm.status = True
|
||||
plugins2settings_manager.save()
|
||||
plugins_manager.save()
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"WEB_UI POST /webui/plugins model:{plugin.model} 发生错误 {type(e)}:{e}"
|
||||
)
|
||||
return Result(
|
||||
code=500,
|
||||
data=f"WEB_UI POST /webui/plugins model:{plugin.model} 发生错误 {type(e)}:{e}",
|
||||
)
|
||||
for key in plugins2settings_manager.keys():
|
||||
if isinstance(plugins2settings_manager[key].cmd, str):
|
||||
plugins2settings_manager[key].cmd = plugins2settings_manager[key].cmd.split(
|
||||
","
|
||||
)
|
||||
plugins2settings_manager.save()
|
||||
plugins_manager.save()
|
||||
return Result(code=200, data="修改成功!")
|
||||
logger.error("调用API错误", "/update_plugins", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
return Result.ok(info="已经帮你写好啦!")
|
||||
|
||||
|
||||
@router.post("/update_config", dependencies=[authentication()])
|
||||
def _(config_list: List[UpdateConfig]) -> Result:
|
||||
try:
|
||||
for config in config_list:
|
||||
if cg := Config.get(config.module):
|
||||
if c := cg.configs.get(config.key):
|
||||
if isinstance(c.value, (list, tuple)) or isinstance(
|
||||
c.default_value, (list, tuple)
|
||||
):
|
||||
value = config.value.split(",")
|
||||
else:
|
||||
value = config.value
|
||||
if c.type and value is not None:
|
||||
value = cattrs.structure(value, c.type)
|
||||
Config.set_config(config.module, config.key, value)
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/update_config", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
Config.save(save_simple_data=True)
|
||||
return Result.ok(info="写入配置项了哦!")
|
||||
|
||||
@@ -1,69 +1,87 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from configs.config import NICKNAME
|
||||
from models.group_info import GroupInfo
|
||||
from services.log import logger
|
||||
from utils.manager import requests_manager
|
||||
from utils.utils import get_bot
|
||||
|
||||
from ..auth import Depends, User, token_to_user
|
||||
from ..config import *
|
||||
from ..models.model import RequestResult, Result
|
||||
from ..models.params import HandleRequest
|
||||
from ..utils import authentication
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/webui/request", dependencies=[token_to_user()])
|
||||
def _(type_: Optional[str]) -> Result:
|
||||
req_data = requests_manager.get_data()
|
||||
req_list = []
|
||||
if type_ in ["group", "private"]:
|
||||
req_data = req_data[type_]
|
||||
for x in req_data:
|
||||
req_data[x]["oid"] = x
|
||||
req_list.append(RequestResult(**req_data[x]))
|
||||
req_list.reverse()
|
||||
return Result(code=200, data=req_list)
|
||||
@router.get("/get_request", dependencies=[authentication()])
|
||||
def _(request_type: Optional[str]) -> Result:
|
||||
try:
|
||||
req_data = requests_manager.get_data()
|
||||
req_list = []
|
||||
if request_type in ["group", "private"]:
|
||||
req_data = req_data[request_type]
|
||||
for x in req_data:
|
||||
req_data[x]["oid"] = x
|
||||
req_list.append(RequestResult(**req_data[x]))
|
||||
req_list.reverse()
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/get_request", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
return Result.ok(req_list, f"{NICKNAME}带来了最新的数据!")
|
||||
|
||||
|
||||
@router.delete("/webui/request", dependencies=[token_to_user()])
|
||||
def _(type_: Optional[str]) -> Result:
|
||||
@router.delete("/clear_request", dependencies=[authentication()])
|
||||
def _(request_type: Optional[str]) -> Result:
|
||||
"""
|
||||
清空请求
|
||||
:param type_: 类型
|
||||
"""
|
||||
requests_manager.clear(type_)
|
||||
return Result(code=200)
|
||||
requests_manager.clear(request_type)
|
||||
return Result.ok(info="成功清除了数据")
|
||||
|
||||
|
||||
@router.post("/webui/request", dependencies=[token_to_user()])
|
||||
async def _(parma: RequestParma) -> Result:
|
||||
@router.post("/handle_request", dependencies=[authentication()])
|
||||
async def _(parma: HandleRequest) -> Result:
|
||||
"""
|
||||
操作请求
|
||||
:param parma: 参数
|
||||
"""
|
||||
result = "操作成功!"
|
||||
flag = 3
|
||||
if bot := get_bot():
|
||||
if parma.handle == "approve":
|
||||
if parma.type == "group":
|
||||
if rid := requests_manager.get_group_id(parma.id):
|
||||
# await GroupInfo.update_or_create(defaults={"group_flag": 1}, )
|
||||
if group := await GroupInfo.filter(group_id=rid).first():
|
||||
await group.update_or_create(group_flag=1)
|
||||
else:
|
||||
group_info = await bot.get_group_info(group_id=rid)
|
||||
await GroupInfo.update_or_create(
|
||||
group_id=group_info["group_id"],
|
||||
defaults={
|
||||
"group_name": group_info["group_name"],
|
||||
"max_member_count": group_info["max_member_count"],
|
||||
"member_count": group_info["member_count"],
|
||||
"group_flag": 1,
|
||||
},
|
||||
)
|
||||
flag = await requests_manager.approve(bot, parma.id, parma.type)
|
||||
elif parma.handle == "refuse":
|
||||
flag = await requests_manager.refused(bot, parma.id, parma.type)
|
||||
elif parma.handle == "delete":
|
||||
requests_manager.delete_request(parma.id, parma.type)
|
||||
if parma.handle != "delete":
|
||||
if flag == 1:
|
||||
result = "该请求已失效"
|
||||
try:
|
||||
result = "操作成功!"
|
||||
flag = 3
|
||||
if bot := get_bot():
|
||||
if parma.handle == "approve":
|
||||
if parma.type == "group":
|
||||
if rid := requests_manager.get_group_id(parma.id):
|
||||
# await GroupInfo.update_or_create(defaults={"group_flag": 1}, )
|
||||
if group := await GroupInfo.get_or_none(group_id=rid):
|
||||
await group.update_or_create(group_flag=1)
|
||||
else:
|
||||
group_info = await bot.get_group_info(group_id=rid)
|
||||
await GroupInfo.update_or_create(
|
||||
group_id=group_info["group_id"],
|
||||
defaults={
|
||||
"group_name": group_info["group_name"],
|
||||
"max_member_count": group_info["max_member_count"],
|
||||
"member_count": group_info["member_count"],
|
||||
"group_flag": 1,
|
||||
},
|
||||
)
|
||||
flag = await requests_manager.approve(bot, parma.id, parma.type)
|
||||
elif parma.handle == "refuse":
|
||||
flag = await requests_manager.refused(bot, parma.id, parma.type)
|
||||
elif parma.handle == "delete":
|
||||
requests_manager.delete_request(parma.id, parma.type)
|
||||
elif flag == 2:
|
||||
result = "未找到此Id"
|
||||
return Result(code=200, data=result)
|
||||
if parma.handle != "delete":
|
||||
if flag == 1:
|
||||
result = "该请求已失效"
|
||||
requests_manager.delete_request(parma.id, parma.type)
|
||||
elif flag == 2:
|
||||
result = "未找到此Id"
|
||||
return Result.ok(result, "成功处理了请求!")
|
||||
return Result.fail("Bot未连接")
|
||||
except Exception as e:
|
||||
logger.error("调用API错误", "/get_group", e=e)
|
||||
return Result.fail(f"{type(e)}: {e}")
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import asyncio
|
||||
import os
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
import psutil
|
||||
import ujson as json
|
||||
from fastapi import APIRouter
|
||||
|
||||
from configs.path_config import (
|
||||
DATA_PATH,
|
||||
@@ -17,8 +20,15 @@ from configs.path_config import (
|
||||
from services.log import logger
|
||||
from utils.http_utils import AsyncHttpx
|
||||
|
||||
from ..auth import Depends, User, token_to_user
|
||||
from ..config import *
|
||||
from ..models.model import (
|
||||
Result,
|
||||
SystemFolderSize,
|
||||
SystemNetwork,
|
||||
SystemResult,
|
||||
SystemStatus,
|
||||
SystemStatusList,
|
||||
)
|
||||
from ..utils import authentication
|
||||
|
||||
CPU_DATA_PATH = DATA_PATH / "system" / "cpu.json"
|
||||
MEMORY_DATA_PATH = DATA_PATH / "system" / "memory.json"
|
||||
@@ -28,31 +38,31 @@ cpu_data = {"data": []}
|
||||
memory_data = {"data": []}
|
||||
disk_data = {"data": []}
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/system", dependencies=[token_to_user()])
|
||||
|
||||
@router.get("/system", dependencies=[authentication()])
|
||||
async def _() -> Result:
|
||||
return await get_system_data()
|
||||
|
||||
|
||||
@router.get("/webui/system/status", dependencies=[token_to_user()])
|
||||
@router.get("/status", dependencies=[authentication()])
|
||||
async def _() -> Result:
|
||||
return Result(
|
||||
code=200,
|
||||
data=await asyncio.get_event_loop().run_in_executor(None, _get_system_status),
|
||||
return Result.ok(
|
||||
await asyncio.get_event_loop().run_in_executor(None, _get_system_status),
|
||||
)
|
||||
|
||||
|
||||
@router.get("/webui/system/disk", dependencies=[token_to_user()])
|
||||
@router.get("/system/disk", dependencies=[authentication()])
|
||||
async def _(type_: Optional[str] = None) -> Result:
|
||||
return Result(
|
||||
code=200,
|
||||
return Result.ok(
|
||||
data=await asyncio.get_event_loop().run_in_executor(
|
||||
None, _get_system_disk, type_
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@router.get("/webui/system/statusList", dependencies=[token_to_user()])
|
||||
@router.get("/system/statusList", dependencies=[authentication()])
|
||||
async def _() -> Result:
|
||||
global cpu_data, memory_data, disk_data
|
||||
await asyncio.get_event_loop().run_in_executor(None, _get_system_status)
|
||||
@@ -65,9 +75,8 @@ async def _() -> Result:
|
||||
disk_rst = (
|
||||
disk_data["data"][-10:] if len(disk_data["data"]) > 10 else disk_data["data"]
|
||||
)
|
||||
return Result(
|
||||
code=200,
|
||||
data=SystemStatusList(
|
||||
return Result.ok(
|
||||
SystemStatusList(
|
||||
cpu_data=cpu_rst,
|
||||
memory_data=memory_rst,
|
||||
disk_data=disk_rst,
|
||||
@@ -95,12 +104,11 @@ async def get_system_data():
|
||||
network = SystemNetwork(baidu=baidu, google=google)
|
||||
disk = await asyncio.get_event_loop().run_in_executor(None, _get_system_disk, None)
|
||||
status = await asyncio.get_event_loop().run_in_executor(None, _get_system_status)
|
||||
return Result(
|
||||
code=200,
|
||||
data=SystemResult(
|
||||
return Result.ok(
|
||||
SystemResult(
|
||||
status=status,
|
||||
network=network,
|
||||
disk=disk,
|
||||
disk=disk, # type: ignore
|
||||
check_time=datetime.now().replace(microsecond=0),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user