diff options
author | wu.zhihui <wu.zhihui1@zte.com.cn> | 2016-10-12 15:32:52 +0800 |
---|---|---|
committer | wu.zhihui <wu.zhihui1@zte.com.cn> | 2016-10-14 17:16:00 +0800 |
commit | eddc35b497362c0c01e612d66ed19c4d5c9dd328 (patch) | |
tree | 9a9c792a002fce40782158b9d645e597d3606f1b /utils/report/get_results.py | |
parent | 975e241de4d4bf3839c788ad743d0cc077e23bd4 (diff) |
Adjust directory structure
qtip
!
+---- scripts
! !
! +----ref_result # python scripts to generate results report
! +----fetch_compute_ips.sh
! +----fetch_os_creds.sh
! +----file_permission.sh
! +----get_env_info.sh
! +----qtip_creds.sh
! +----ssh_exch.exp
!
+---- config
! !
! +---- Qtip_key
! +---- Qtip_key.pub
! +---- SampleHeat.yaml
!
+---- utils
! !
! +---- logger_utils.py
! +---- report # generate pdf report file
Change-Id: Ia908ff31494369c1a13fb88b1ff9b0e5681f8e29
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'utils/report/get_results.py')
-rw-r--r-- | utils/report/get_results.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/utils/report/get_results.py b/utils/report/get_results.py new file mode 100644 index 00000000..23fd5383 --- /dev/null +++ b/utils/report/get_results.py @@ -0,0 +1,50 @@ +import os +import json + + +def report_concat(targ_dir, testcase): + machine_temp = [] + machines = [] + + for file in os.listdir(targ_dir): + if file.endswith(".json"): + machine_temp.append(file) + + l = len(machine_temp) + + for x in range(0, l): + file_t = machine_temp[x] + with open(targ_dir + file_t) as result_file: + result_djson = json.load(result_file) + if result_djson['1 Testcase Name'] == str(testcase): + machines.append(result_djson) + return machines + + +def space_count(l): + spc = '' + for x in range(l): + spc = spc + ' ' + return spc + + +def custom_dict(list1, list2, k): + string_1 = '' + for num_1 in range(0, len(list1)): + string_1 = string_1 + space_count(k) + str(list1[num_1][0]) + "=" + str(list2[num_1]) + "\n" + return string_1 + + +def generate_result(dict_a, k): + list_1 = [] + list_2 = [] + count = 0 + for i, j in sorted(dict_a.iteritems()): + list_1.append([]) + list_1[count].append(i) + if (str(type(dict_a.get(i)))) == "<type 'dict'>": + list_2.append(str("\n" + generate_result(dict_a.get(i), int(k + 1)))) + else: + list_2.append(dict_a.get(i)) + count = count + 1 + return custom_dict(list_1, list_2, k) |