[libvirt PATCH 17/29] cpu-gather: Transport data as json

Tim Wiederhake twiederh at redhat.com
Tue Dec 15 16:25:03 UTC 2020


More reliable, easier to parse, easier to edit.

Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 tests/cputestdata/cpu-gather.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py
index 83f175d342..7c51a47353 100755
--- a/tests/cputestdata/cpu-gather.py
+++ b/tests/cputestdata/cpu-gather.py
@@ -193,9 +193,12 @@ def gather(args):
 
 
 def parse(args):
+    data = json.load(sys.stdin)
+
     os.environ["CPU_GATHER_PY"] = "true"
     output = subprocess.check_output(
         "./cpu-parse.sh",
+        input=output_to_text(data),
         stderr=subprocess.STDOUT,
         universal_newlines=True)
     print(output)
@@ -267,7 +270,7 @@ def main():
 
     if args.gather:
         data = gather(args)
-        print(output_to_text(data))
+        json.dump(data, sys.stdout, indent=2)
     else:
         parse(args)
 
-- 
2.26.2




More information about the libvir-list mailing list