added inxi into snap. (#78)

* added inxi into snap.

* remove errors for inxi that occurs in snap env
This commit is contained in:
Vadym Stupakov 2020-08-06 20:51:48 +03:00 committed by GitHub
parent 35d6cb6519
commit 6a633a7e52
2 changed files with 13 additions and 6 deletions

View File

@ -19,6 +19,8 @@ parts:
- gcc
- python3-dev
- python3-wheel
stage-packages:
- inxi
source: .
deploy-cpufrectl:

View File

@ -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