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): |
---|
39 | |
---|
40 | compile_list = glob.glob(maindir+"/build_*.txt") |
---|
41 | if len(compile_list) == 0 : |
---|
42 | return |
---|
43 | |
---|
44 | machine = maindir.replace("build_","") |
---|
45 | revision_list=[] |
---|
46 | machine_list=[] |
---|
47 | arch_list=[] |
---|
48 | mode_list=[] |
---|
49 | |
---|
50 | bg_color = ["#84c5ff", "#96cdff", "#a1d3ff", "#b3dafd", "#c2e1fd"] |
---|
51 | |
---|
52 | |
---|
53 | myBuild=["", "", "", "", ""] #revision, machine, arch, mode, status |
---|
54 | myBuildList=[] |
---|
55 | |
---|
56 | for compile_log in compile_list: |
---|
57 | revision = compile_log[6:10] |
---|
58 | |
---|
59 | f=open(compile_log, "r") |
---|
60 | for line in f: |
---|
61 | if line.startswith("revision"): |
---|
62 | myText = line.replace("revision ", "").replace("\n", "") |
---|
63 | if not myText in revision_list: |
---|
64 | revision_list.append(myText) |
---|
65 | myBuild[0] = myText |
---|
66 | |
---|
67 | |
---|
68 | elif line.startswith("machine"): |
---|
69 | myText = line.replace("machine ", "").replace("\n", "") |
---|
70 | if not myText in machine_list: |
---|
71 | machine_list.append(myText) |
---|
72 | myBuild[1] = myText |
---|
73 | |
---|
74 | elif line.startswith("arch"): |
---|
75 | myText = line.replace("arch ", "").replace("\n", "") |
---|
76 | if not myText in arch_list: |
---|
77 | arch_list.append(myText) |
---|
78 | myBuild[2] = myText |
---|
79 | |
---|
80 | elif line.startswith("mode"): |
---|
81 | myText = line.replace("mode ", "").replace("\n", "") |
---|
82 | if not myText in mode_list: |
---|
83 | mode_list.append(myText) |
---|
84 | myBuild[3] = myText |
---|
85 | |
---|
86 | elif line.startswith("Build command"): |
---|
87 | myTexts = line.replace("Build command ", "").replace("\n", "").split(" ") |
---|
88 | if myTexts[0] == "finished" : |
---|
89 | myBuild[4] = "✅" |
---|
90 | else : |
---|
91 | myBuild[4] = "❌" |
---|
92 | myBuildList.append([myBuild[0], myBuild[1], myBuild[2], myBuild[3], myBuild[4]]) |
---|
93 | f.close() |
---|
94 | |
---|
95 | print(Sort(myBuildList)) # first by revision number, then by mode, then by arch. all in descendant order |
---|
96 | print(len(myBuildList)) |
---|
97 | |
---|
98 | revision_list = sorted(revision_list, reverse = True) |
---|
99 | print(arch_list) # row |
---|
100 | print(mode_list) # col |
---|
101 | print(machine_list) # col |
---|
102 | print(revision_list) # col |
---|
103 | |
---|
104 | |
---|
105 | f=open("compile_"+machine+"_info.js", "w") |
---|
106 | f.write("var "+machine+"_compile_info_list = "+repr(myBuildList)+"\n\n") |
---|
107 | f.write("var "+machine+"_revision_list = "+repr(revision_list)+"\n\n") |
---|
108 | f.close() |
---|
109 | |
---|
110 | |
---|
111 | def main() : |
---|
112 | subgenerate("build_jeanzay") |
---|
113 | subgenerate("build_irene") |
---|
114 | |
---|
115 | if __name__== "__main__": |
---|
116 | main() |
---|