From 731f07e0624c6d951716ab631e423137cae681e9 Mon Sep 17 00:00:00 2001 From: snowy Date: Fri, 5 Apr 2024 09:27:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CPU=E9=A2=91=E7=8E=87=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BD=8D=E6=95=B0=E8=B6=85=E5=87=BA=E8=8C=83=E5=9B=B4=20fix:?= =?UTF-8?q?=20=E7=A9=BA=E9=A9=B1=E5=8A=A8=E5=99=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=9C=A8=E9=9D=A2=E6=9D=BF=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/liteyuki_main/runtime.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/liteyuki/liteyuki_main/runtime.py b/liteyuki/liteyuki_main/runtime.py index 5b036186..a457b966 100644 --- a/liteyuki/liteyuki_main/runtime.py +++ b/liteyuki/liteyuki_main/runtime.py @@ -128,14 +128,15 @@ async def get_stats_data(self_id: str = None, lang: str = None): disk_usage = psutil.disk_usage(disk.mountpoint) disk_total_show = convert_size(disk_usage.total, 1) disk_free_show = convert_size(disk_usage.free, 1) - disk_data.append( - { - "name" : disk.device, - "total" : disk_total_show, - "free" : disk_free_show, - "percent": disk_usage.percent, - } - ) + if disk_usage.total > 0: + disk_data.append( + { + "name" : disk.device, + "total" : disk_total_show, + "free" : disk_free_show, + "percent": disk_usage.percent, + } + ) cpu_info = get_cpu_info() if "AMD" in cpu_info.get("brand_raw", ""): @@ -191,7 +192,7 @@ async def get_stats_data(self_id: str = None, lang: str = None): f"{brand} {cpu_info.get('arch', 'Unknown')}", f"{fake_device_info.get('cpu', {}).get('cores', psutil.cpu_count(logical=False))}C " f"{fake_device_info.get('cpu', {}).get('logical_cores', psutil.cpu_count(logical=True))}T", - f"{fake_device_info.get('cpu', {}).get('frequency', psutil.cpu_freq().current) / 1000}GHz" + f"{'%.2f' % (fake_device_info.get('cpu', {}).get('frequency', psutil.cpu_freq().current) / 1000)}GHz" ], "memTags" : [ f"Bot {mem_used_bot_show}",