]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu-gather: Create python wrapper for shell script
authorTim Wiederhake <twiederh@redhat.com>
Tue, 15 Dec 2020 16:24:48 +0000 (17:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 22:19:31 +0000 (23:19 +0100)
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>
tests/cputestdata/cpu-gather.py [new file with mode: 0755]
tests/cputestdata/cpu-gather.sh
tests/cputestdata/cpu-parse.sh

diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py
new file mode 100755 (executable)
index 0000000..f7030eb
--- /dev/null
@@ -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()
index 7574324d1ca07917275f770a0e762f00c9bc5b86..cd65d74da5e2c6734cea78cdca34aa4b4c8e6129 100755 (executable)
@@ -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
index 7501c57cba8f200b07cf8b855faca4de597fd000..2981e9193c1e6379b8545228aef766fb9e63ef45 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # Usage:
-# ./cpu-gather.sh | ./cpu-parse.sh
+# ./cpu-gather.py | ./cpu-parse.sh
 
 data=`cat`