summaryrefslogtreecommitdiffstats
path: root/scripts/lib/resulttool/resultutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/resulttool/resultutils.py')
-rw-r--r--scripts/lib/resulttool/resultutils.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/lib/resulttool/resultutils.py b/scripts/lib/resulttool/resultutils.py
index ad40ac8499..aab312dd17 100644
--- a/scripts/lib/resulttool/resultutils.py
+++ b/scripts/lib/resulttool/resultutils.py
@@ -16,6 +16,8 @@ import os
16import json 16import json
17import scriptpath 17import scriptpath
18import copy 18import copy
19import urllib
20import posixpath
19scriptpath.add_oe_lib_path() 21scriptpath.add_oe_lib_path()
20 22
21flatten_map = { 23flatten_map = {
@@ -40,20 +42,33 @@ store_map = {
40 "manual": ['TEST_TYPE', 'TEST_MODULE', 'MACHINE', 'IMAGE_BASENAME'] 42 "manual": ['TEST_TYPE', 'TEST_MODULE', 'MACHINE', 'IMAGE_BASENAME']
41} 43}
42 44
45def is_url(p):
46 """
47 Helper for determining if the given path is a URL
48 """
49 return p.startswith('http://') or p.startswith('https://')
50
43# 51#
44# Load the json file and append the results data into the provided results dict 52# Load the json file and append the results data into the provided results dict
45# 53#
46def append_resultsdata(results, f, configmap=store_map): 54def append_resultsdata(results, f, configmap=store_map):
47 if type(f) is str: 55 if type(f) is str:
48 with open(f, "r") as filedata: 56 if is_url(f):
49 data = json.load(filedata) 57 with urllib.request.urlopen(f) as response:
58 data = json.loads(response.read().decode('utf-8'))
59 url = urllib.parse.urlparse(f)
60 testseries = posixpath.basename(posixpath.dirname(url.path))
61 else:
62 with open(f, "r") as filedata:
63 data = json.load(filedata)
64 testseries = os.path.basename(os.path.dirname(f))
50 else: 65 else:
51 data = f 66 data = f
52 for res in data: 67 for res in data:
53 if "configuration" not in data[res] or "result" not in data[res]: 68 if "configuration" not in data[res] or "result" not in data[res]:
54 raise ValueError("Test results data without configuration or result section?") 69 raise ValueError("Test results data without configuration or result section?")
55 if "TESTSERIES" not in data[res]["configuration"]: 70 if "TESTSERIES" not in data[res]["configuration"]:
56 data[res]["configuration"]["TESTSERIES"] = os.path.basename(os.path.dirname(f)) 71 data[res]["configuration"]["TESTSERIES"] = testseries
57 testtype = data[res]["configuration"].get("TEST_TYPE") 72 testtype = data[res]["configuration"].get("TEST_TYPE")
58 if testtype not in configmap: 73 if testtype not in configmap:
59 raise ValueError("Unknown test type %s" % testtype) 74 raise ValueError("Unknown test type %s" % testtype)
@@ -69,7 +84,7 @@ def append_resultsdata(results, f, configmap=store_map):
69# 84#
70def load_resultsdata(source, configmap=store_map): 85def load_resultsdata(source, configmap=store_map):
71 results = {} 86 results = {}
72 if os.path.isfile(source): 87 if is_url(source) or os.path.isfile(source):
73 append_resultsdata(results, source, configmap) 88 append_resultsdata(results, source, configmap)
74 return results 89 return results
75 for root, dirs, files in os.walk(source): 90 for root, dirs, files in os.walk(source):