1 | import glob |
---|
2 | import sys |
---|
3 | import subprocess |
---|
4 | import os |
---|
5 | import copy |
---|
6 | |
---|
7 | def OSinfo(runthis): |
---|
8 | red = lambda text: '\033[0;31m' + text + '\033[0m' |
---|
9 | osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) |
---|
10 | theInfo = osstdout.communicate()[0].strip() |
---|
11 | if osstdout.returncode!=0: |
---|
12 | print(red(runthis+" FAILED")) |
---|
13 | print >> sys.stderr, osstdout.returncode |
---|
14 | sys.exit() |
---|
15 | # else: |
---|
16 | # print(runthis+" OK") |
---|
17 | |
---|
18 | def Sort(sub_li): |
---|
19 | l = len(sub_li) |
---|
20 | for i in range(0, l): |
---|
21 | for j in range(0, l-i-1): |
---|
22 | if (sub_li[j][0] < sub_li[j+1][0]): |
---|
23 | tempo = sub_li[j] |
---|
24 | sub_li[j]= sub_li[j+1] |
---|
25 | sub_li[j+1]= tempo |
---|
26 | if (sub_li[j][0] == sub_li[j+1][0]): |
---|
27 | if (sub_li[j][3] < sub_li[j+1][3]): |
---|
28 | tempo = sub_li[j] |
---|
29 | sub_li[j]= sub_li[j+1] |
---|
30 | sub_li[j+1]= tempo |
---|
31 | if (sub_li[j][3] == sub_li[j+1][3]): |
---|
32 | if (sub_li[j][2] < sub_li[j+1][2]): |
---|
33 | tempo = sub_li[j] |
---|
34 | sub_li[j]= sub_li[j+1] |
---|
35 | sub_li[j+1]= tempo |
---|
36 | return sub_li |
---|
37 | |
---|
38 | def subgenerate(maindir, machine_name): |
---|
39 | |
---|
40 | compile_list = glob.glob(maindir+"/build_"+machine_name+"/build_*.txt") |
---|
41 | print(maindir) |
---|
42 | print(compile_list) |
---|
43 | if len(compile_list) == 0 : |
---|
44 | return |
---|
45 | machine = machine_name |
---|
46 | revision_list=[] |
---|
47 | machine_list=[] |
---|
48 | arch_list=[] |
---|
49 | mode_list=[] |
---|
50 | |
---|
51 | bg_color = ["#84c5ff", "#96cdff", "#a1d3ff", "#b3dafd", "#c2e1fd"] |
---|
52 | |
---|
53 | |
---|
54 | myBuild=["", "", "", "", ""] #revision, machine, arch, mode, status |
---|
55 | myBuildList=[] |
---|
56 | |
---|
57 | for compile_log in compile_list: |
---|
58 | revision = compile_log[6:10] |
---|
59 | myBuild[4] = "❌" |
---|
60 | f=open(compile_log, "r") |
---|
61 | for line in f: |
---|
62 | if line.startswith("revision"): |
---|
63 | myText = line.replace("revision ", "").replace("\n", "") |
---|
64 | if not myText in revision_list: |
---|
65 | revision_list.append(myText) |
---|
66 | myBuild[0] = myText |
---|
67 | |
---|
68 | |
---|
69 | elif line.startswith("machine"): |
---|
70 | myText = line.replace("machine ", "").replace("\n", "") |
---|
71 | if not myText in machine_list: |
---|
72 | machine_list.append(myText) |
---|
73 | myBuild[1] = myText |
---|
74 | |
---|
75 | elif line.startswith("arch"): |
---|
76 | myText = line.replace("arch ", "").replace("\n", "") |
---|
77 | if not myText in arch_list: |
---|
78 | arch_list.append(myText) |
---|
79 | myBuild[2] = myText |
---|
80 | |
---|
81 | elif line.startswith("mode"): |
---|
82 | myText = line.replace("mode ", "").replace("\n", "") |
---|
83 | if not myText in mode_list: |
---|
84 | mode_list.append(myText) |
---|
85 | myBuild[3] = myText |
---|
86 | |
---|
87 | elif line[0].isdigit(): |
---|
88 | myTexts = line.replace("\n", "") |
---|
89 | if myTexts == "0" : |
---|
90 | myBuild[4] = "✅" |
---|
91 | myBuildList.append([myBuild[0], myBuild[1], myBuild[2], myBuild[3], myBuild[4]]) |
---|
92 | f.close() |
---|
93 | |
---|
94 | print(Sort(myBuildList)) # first by revision number, then by mode, then by arch. all in descendant order |
---|
95 | print(len(myBuildList)) |
---|
96 | |
---|
97 | revision_list = sorted(revision_list, reverse = True) |
---|
98 | print(arch_list) # row |
---|
99 | print(mode_list) # col |
---|
100 | print(machine_list) # col |
---|
101 | print(revision_list) # col |
---|
102 | |
---|
103 | |
---|
104 | f=open("compile_"+machine+"_info.js", "w") |
---|
105 | f.write("var "+machine+"_compile_info_list = "+repr(myBuildList)+"\n\n") |
---|
106 | f.write("var "+machine+"_revision_list = "+repr(revision_list)+"\n\n") |
---|
107 | f.close() |
---|
108 | |
---|
109 | |
---|
110 | def main() : |
---|
111 | repository_name=os.getenv('xios_test_suite_repository') |
---|
112 | machine_name=os.getenv('xios_machine_name') |
---|
113 | subgenerate(repository_name+'/BUILD',machine_name) |
---|
114 | |
---|
115 | if __name__== "__main__": |
---|
116 | main() |
---|