From a77f97fd4bb94b18e973486129bab55d53ed6cde Mon Sep 17 00:00:00 2001 From: snowykami Date: Sun, 29 Sep 2024 22:57:04 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20hotfix:=20=E7=A7=BB=E9=99=A4=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=8D=A1=E7=89=87Linux=E4=B8=8B=E9=9D=9E=E5=82=A8?= =?UTF-8?q?=E5=AD=98=E5=88=86=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nonebot_plugins/liteyuki_status/api.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/nonebot_plugins/liteyuki_status/api.py b/src/nonebot_plugins/liteyuki_status/api.py index cda3b508..29287940 100644 --- a/src/nonebot_plugins/liteyuki_status/api.py +++ b/src/nonebot_plugins/liteyuki_status/api.py @@ -64,6 +64,8 @@ data - percent: float - total: int """ + + # status_card_cache = {} # lang -> bytes @@ -90,11 +92,11 @@ data # 获取状态卡片 # bot_id 参数已经是bot参数的一部分了,不需要保留,但为了“兼容性”…… async def generate_status_card( - bot: dict, - hardware: dict, - liteyuki: dict, - lang="zh-CN", - bot_id="0", + bot: dict, + hardware: dict, + liteyuki: dict, + lang="zh-CN", + bot_id="0", ) -> bytes: return await template2image( get_path("templates/status.html", abs_path=True), @@ -269,7 +271,9 @@ async def get_hardware_data() -> dict: for disk in psutil.disk_partitions(all=True): try: disk_usage = psutil.disk_usage(disk.mountpoint) - if disk_usage.total == 0: + if disk_usage.total == 0 or disk.mountpoint.startswith( + ("/var", "/boot", "/run", "/proc", "/sys", "/dev", "/tmp", "/snap") + ): continue # 虚拟磁盘 result["disk"].append( { @@ -297,7 +301,7 @@ async def get_liteyuki_data() -> dict: "python": f"{platform.python_implementation()} {platform.python_version()}", "system": f"{platform.system()} {platform.release()}", "runtime": time.time() - - temp_data.data.get("start_time", time.time()), # 运行时间秒数 + - temp_data.data.get("start_time", time.time()), # 运行时间秒数 "bots": len(nonebot.get_bots()), } return result