提交 ac5d4e6c 编写于 作者: J Jiri Denemark

cputest: Use python3 in CPU parser scripts

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 78b148c3
#!/usr/bin/env python2 #!/usr/bin/env python3
import os import os
import sys import sys
...@@ -259,7 +259,7 @@ def parseQemu(path, features): ...@@ -259,7 +259,7 @@ def parseQemu(path, features):
with open(path, "r") as f: with open(path, "r") as f:
data, pos = json.JSONDecoder().raw_decode(f.read()) data, pos = json.JSONDecoder().raw_decode(f.read())
for (prop, val) in data["return"]["model"]["props"].iteritems(): for (prop, val) in data["return"]["model"]["props"].items():
if val and prop in features: if val and prop in features:
cpuidAdd(cpuid, features[prop]) cpuidAdd(cpuid, features[prop])
...@@ -268,7 +268,7 @@ def parseQemu(path, features): ...@@ -268,7 +268,7 @@ def parseQemu(path, features):
def parseCpuid(path): def parseCpuid(path):
cpuid = {} cpuid = {}
with open(path, "r") as f: with open(path, "rb") as f:
data = xmltodict.parse(f) data = xmltodict.parse(f)
for leaf in data["cpudata"]["cpuid"]: for leaf in data["cpudata"]["cpuid"]:
...@@ -302,7 +302,7 @@ def parseFeature(data): ...@@ -302,7 +302,7 @@ def parseFeature(data):
def parseMap(): def parseMap():
path = os.path.dirname(sys.argv[0]) path = os.path.dirname(sys.argv[0])
path = os.path.join(path, "..", "..", "src", "cpu_map", "x86_features.xml") path = os.path.join(path, "..", "..", "src", "cpu_map", "x86_features.xml")
with open(path, "r") as f: with open(path, "rb") as f:
data = xmltodict.parse(f) data = xmltodict.parse(f)
cpuMap = {} cpuMap = {}
...@@ -313,7 +313,7 @@ def parseMap(): ...@@ -313,7 +313,7 @@ def parseMap():
def formatCpuid(cpuid, path, comment): def formatCpuid(cpuid, path, comment):
print path print(path)
with open(path, "w") as f: with open(path, "w") as f:
f.write("<!-- " + comment + " -->\n") f.write("<!-- " + comment + " -->\n")
f.write("<cpudata arch='x86'>\n") f.write("<cpudata arch='x86'>\n")
...@@ -337,7 +337,7 @@ def convert(path): ...@@ -337,7 +337,7 @@ def convert(path):
for name in feature["names"]: for name in feature["names"]:
props[name] = value props[name] = value
print path print(path)
with open(path, "w") as f: with open(path, "w") as f:
json.dump({"return": {"model": {"name": "base", "props": props}}, json.dump({"return": {"model": {"name": "base", "props": props}},
"id": "model-expansion"}, "id": "model-expansion"},
...@@ -373,7 +373,7 @@ def diff(cpuMap, path): ...@@ -373,7 +373,7 @@ def diff(cpuMap, path):
if len(sys.argv) < 3: if len(sys.argv) < 3:
print "Usage: %s convert|diff json_file..." % sys.argv[0] print("Usage: %s convert|diff json_file..." % sys.argv[0])
sys.exit(1) sys.exit(1)
action = sys.argv[1] action = sys.argv[1]
...@@ -387,5 +387,5 @@ elif action == "diff": ...@@ -387,5 +387,5 @@ elif action == "diff":
for path in args: for path in args:
diff(cpuMap, path) diff(cpuMap, path)
else: else:
print "Unknown action: " + action print("Unknown action: %s" % action)
sys.exit(1) sys.exit(1)
#!/usr/bin/env python #!/usr/bin/env python3
import sys import sys
import json import json
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册