From ac5bea656e43e4216f9c63a78f7b1dd5d786003f Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 3 Jul 2022 21:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B3=BB=E7=BB=9F=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/system_api.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/class/core/system_api.py b/class/core/system_api.py index f16705521..80ad6ae9e 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -243,13 +243,19 @@ class system_api: mac_version += x.split("\t")[1] + ' ' return mac_version - version = mw.readFile('/etc/redhat-release') - if not version: - version = mw.readFile( - '/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip() - else: + redhat_series = '/etc/redhat-release' + if os.path.exists(redhat_series): + version = mw.readFile('/etc/redhat-release') version = version.replace('release ', '').strip() - return version + return version + + os_series = '/etc/os-release' + if os.path.exists(os_series): + version = mw.execShell( + "cat /etc/*-release | grep PRETTY_NAME | awk -F = '{print $2}' | awk -F '\"' '{print $2}'") + return version[0].strip() + + return '未识别系统信息' def getBootTime(self): # 取系统启动时间