cpu-gather: Create python wrapper for shell script

This changes the invocation from
  ./cpu-gather.sh | ./cpu-parse.sh
to
  ./cpu-gather.py | ./cpu-parse.sh

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2020-12-15 17:24:48 +01:00 committed by Michal Privoznik
parent 9d25f2fe16
commit 34c9db5a4a
3 changed files with 19 additions and 1 deletions

13
tests/cputestdata/cpu-gather.py Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
import os
import subprocess
def main():
os.environ["CPU_GATHER_PY"] = "true"
subprocess.check_call("./cpu-gather.sh")
if __name__ == "__main__":
main()

View File

@ -4,6 +4,11 @@
# distro does not provide such package, you can find the sources or binary
# packages at https://www.etallen.com/cpuid.html
if [ -z "${CPU_GATHER_PY}" ]; then
echo >&2 "Do not call this script directly. Use 'cpu-gather.py' instead."
exit 1
fi
grep 'model name' /proc/cpuinfo | head -n1
cpuid -1r

View File

@ -1,7 +1,7 @@
#!/bin/bash
# Usage:
# ./cpu-gather.sh | ./cpu-parse.sh
# ./cpu-gather.py | ./cpu-parse.sh
data=`cat`