ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/TWikiIB/makeDepMetrics.py
Revision: 1.8
Committed: Tue Sep 8 09:55:25 2009 UTC (15 years, 7 months ago) by geonmo
Content type: text/x-python
Branch: MAIN
Changes since 1.7: +0 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/env python
2 import re, os
3
4 class mkDepMetrics(object) :
5 def __init__(self, page, tday, arch, packagename) :
6 self.page=page
7 self.tday = tday
8 self.arch = arch
9 self.packagename = packagename
10 self.url = 'https://macms01.cern.ch/ap/ignominy/'+arch+'/'+packagename+'/igRun/metrics'
11 temp = os.popen('wget --no-check-certificate -nv -o /dev/null -O- '+self.url)
12 self.contents=[]
13 self.contents = temp.readlines()
14
15
16 def makeSummary(self):
17 contents=self.contents
18 writeflag = False
19 cycleflag = False
20 typeCycle = re.compile('^(Cycle \w*)')
21 for line in contents :
22 matchCycle = typeCycle.search(line)
23 if line=='# Summary\n' :
24 writeflag = True
25 elif line=='# Levels\n' :
26 writeflag = False
27 cycleflag = False
28 self.page.write('</div>\n')
29 self.page.write('''<br><pre>
30 * CCD: Cumulative Component Dependency measures the cumulative testing cost
31 across the system.
32 * ACD: Average Component Dependency indicates the number of other packages
33 an average package depends on.
34 * NCCD: Normalised Cumulative Component Dependency measures how the structure
35 differs from a balanced binary tree of comparable size. If NCCD is one,
36 the structure resembles a binary tree; if much less than one, the
37 packages are mostly independent; if much greater than one, the system
38 is fairly strongly coupled. The only universal NCCD target is to
39 minimise for any given software system--a high value indicates a
40 strongly coupled system and less coupling is better.
41 </pre>
42 <<<<<<< makeDepMetrics.py
43 ''')
44 break
45 elif line=='\n' :
46 continue
47 elif line[0:5] =='* CCD' :
48 writeflag = False
49 elif line=='# Cycles\n' :
50 self.page.write(' * Cycles\n\n')
51 self.page.write('<div id="test">\n')
52 cycleflag=True
53 elif matchCycle and cycleflag :
54 self.page.write(' * '+matchCycle.group(1)+'\n')
55 elif cycleflag :
56 self.page.write(' * !'+line.strip()+'\n')
57 elif writeflag :
58 self.page.write(' * '+line)
59 else :
60 print line
61 continue
62
63
64 def packlist(self):
65 contents=self.contents
66 pack = [['Levels']]
67 j=0
68 writeflag = False
69 valueflag = False
70 if len(contents)==0 :
71 self.page.write('---+++++No data about metrics information.\n')
72 return pack
73 for line in contents :
74 if line =='# Levels\n' :
75 writeflag = True
76 continue
77 elif not writeflag :
78 continue
79 if line=='\n':
80 continue
81 matchLevel = re.search('[0-9]. ',line)
82 if matchLevel :
83 j = j + 1
84 temp = line.split()
85 pack.append(temp)
86 valueflag=True
87 continue
88 if valueflag :
89 if line=='\n' :
90 valueflag=False
91 continue
92 else :
93 temp =line.strip()
94 print temp
95 pack[j].append(temp)
96 return pack
97 # repack return list [[levels], [level1, [PACKEGE1,module1,module2,...], [PACKEGE2,module1,module2], ..],[level2,[],[],...] ...]
98 def repack(self,pack):
99 #print pack
100 listlen = len(pack)
101 pack2 = [['Levels']]
102 countpack = 0
103 for i in range(1,listlen):
104 packname = [[str(i)]]
105 check = 1
106 for j in range(1,len(pack[i])):
107
108 m = re.search('/',pack[i][j])
109 per = m.span()
110 title = pack[i][j][0:per[0]]
111 module = pack[i][j][per[1]:]
112 if j==1:
113 temp = []
114 temp.append(title)
115 packname.append(temp)
116 packname[check].append(module)
117 #print packname[0]
118 else:
119 if packname[check][0]==title:
120 #print 'it\'s work!'
121 packname[check].append(module)
122 else:
123 check = check + 1
124 temp = []
125 temp.append(title)
126 packname.append(temp)
127 packname[check].append(module)
128
129 pack2.append(packname)
130 return pack2
131
132 def dropdown(self,list):
133 self.page.write('\n<div id="test">\n\n')
134 listlen = len(list)
135 for level in range(1,listlen):
136 self.page.write(' * !'+str(list[level][0][0])+'\n')
137 for pack in range(1,len(list[level])):
138 self.page.write(' * !'+str(list[level][pack][0])+'\n')
139 for module in range(1,len(list[level][pack])):
140 self.page.write(' * [[https://macms01.cern.ch/ap/ignominy/'+self.arch+'/'+self.packagename+'/igRun/subsystem.'+str(list[level][pack][0])+'/PROJECT-'+str(list[level][pack][0])+'-'+str(list[level][pack][module].replace('/','-'))+'-O.gif.html]['+str(list[level][pack][module])+']]\n')
141 self.page.write('</div>\n%INCLUDE{"Main.DropDownMenu" section="js" MENU_ID="test"}%\n<br><br>\n\n')
142
143
144
145 if __name__=="__main__" :
146 from makeDepMetrics import mkDepMetrics
147 mkDM = mkDepMetrics('t','slc4_ia32_gcc345','CMSSW_3_1_X_2009-08-05-1200')
148 pkglist = mkDM.packlist()
149 outputlist = mkDM.repack(pkglist)
150 mkDM.dropdown(outputlist)
151