From 6a633a7e523206fbe89c9c45af6913fc9d061bc5 Mon Sep 17 00:00:00 2001 From: Vadym Stupakov Date: Thu, 6 Aug 2020 20:51:48 +0300 Subject: [PATCH] added inxi into snap. (#78) * added inxi into snap. * remove errors for inxi that occurs in snap env --- snap/snapcraft.yaml | 2 ++ source/core.py | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index d7d8725..f9cac60 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -19,6 +19,8 @@ parts: - gcc - python3-dev - python3-wheel + stage-packages: + - inxi source: . deploy-cpufrectl: diff --git a/source/core.py b/source/core.py index b2e590b..8261166 100644 --- a/source/core.py +++ b/source/core.py @@ -60,15 +60,20 @@ def get_sys_info(): Return sys info of inxi command with injected governors information """ govs = " ".join(get_avail_gov()) - govs = f"Governors: {govs}" if shutil.which("inxi") is not None: - sys_info = getoutput("inxi -Fz") - p = re.compile(pattern=r".*(CPU:\s+).+", flags=re.MULTILINE) - indent = " " * len(p.search(sys_info).group(1)) - sys_info = p.sub(f"CPU:{indent[4:]}{govs}", sys_info) + sys_info = getoutput("inxi -Fzc0") + f = re.MULTILINE | re.DOTALL + + # remove errors at the beginning that could occur in the snap container + sys_info = re.fullmatch(r"(.*)(System:.*)", sys_info, flags=f).group(2) + + # insert governors after "CPU:" + p = re.compile(pattern=r"(.*)(CPU:)(\s+)(.+)", flags=f) + indent = " " * len(p.search(sys_info).group(3)) + sys_info = p.sub(fr"\1\2{indent}Governors: {govs}\4", sys_info) else: sys_info = ("Warning: inxi is not installed.\n" - f"{govs}") + f"Governors: {govs}\n") return sys_info