安装脚本添加本地化

This commit is contained in:
远野千束 2024-10-06 04:32:12 +08:00
parent c63d84106b
commit 8e2c5c24b8

View File

@ -10,6 +10,22 @@ from server_status.timezone import get_timezone
excluded_partition_prefix = ("/var", "/boot", "/run", "/proc", "/sys", "/dev", "/tmp", "/snap") excluded_partition_prefix = ("/var", "/boot", "/run", "/proc", "/sys", "/dev", "/tmp", "/snap")
os_name = "" # linux下为发行版名称windows下为Windows
os_version = "" # linux下为发行版版本windows下为Windows版本
try:
# read /etc/os-release
with open("/etc/os-release") as f:
os_release = f.read()
# 找到NAME=和VERSION=的行
for line in os_release.split("\n"):
if line.startswith("NAME="):
os_name = line.split("=")[1]
elif line.startswith("VERSION="):
os_version = line.split("=")[1]
except FileNotFoundError:
os_name = platform.system()
os_version = platform.release()
def log(*args): def log(*args):
# 在输出前加上时间 # 在输出前加上时间
@ -29,6 +45,7 @@ def get_network_speed(interval) -> tuple[int, int]:
class Hardware: class Hardware:
os_release: str = ""
mem_total: int = psutil.virtual_memory().total mem_total: int = psutil.virtual_memory().total
mem_used: int = psutil.virtual_memory().used mem_used: int = psutil.virtual_memory().used
@ -185,10 +202,10 @@ class Client:
"id": self.client_id, "id": self.client_id,
"name": self.name, "name": self.name,
"os": { "os": {
"name": platform.system(), "name": platform.system(), # 系统类型 linux|windows|darwin
"version": platform.version(), "version": os_name + os_version, # 系统版本复杂描述 #1 SMP PREEMPT_DYNAMIC Fri Sep 13 10:42:50 UTC 2024 (5c05eeb)
"machine": platform.machine(), "machine": platform.machine(), # 机器类型 x86_64
"release": platform.release(), "release": os_version, # 系统版本
}, },
"labels": self.labels, "labels": self.labels,
"location": self.location, "location": self.location,