ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/TWikiIB/makeDepMetrics.py
Revision: 1.10
Committed: Tue Sep 8 10:04:03 2009 UTC (15 years, 7 months ago) by geonmo
Content type: text/x-python
Branch: MAIN
Changes since 1.9: +0 -5 lines
Log Message:
remove temp print

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 ''')
43 break
44 elif line=='\n' :
45 continue
46 elif line[0:5] =='* CCD' :
47 writeflag = False
48 elif line=='# Cycles\n' :
49 self.page.write(' * Cycles\n\n')
50 self.page.write('<div id="test">\n')
51 cycleflag=True
52 elif matchCycle and cycleflag :
53 self.page.write(' * '+matchCycle.group(1)+'\n')
54 elif cycleflag :
55 self.page.write(' * !'+line.strip()+'\n')
56 elif writeflag :
57 self.page.write(' * '+line)
58 else :
59 continue
60
61
62 def packlist(self):
63 contents=self.contents
64 pack = [['Levels']]
65 j=0
66 writeflag = False
67 valueflag = False
68 if len(contents)==0 :
69 self.page.write('---+++++No data about metrics information.\n')
70 return pack
71 for line in contents :
72 if line =='# Levels\n' :
73 writeflag = True
74 continue
75 elif not writeflag :
76 continue
77 if line=='\n':
78 continue
79 matchLevel = re.search('[0-9]. ',line)
80 if matchLevel :
81 j = j + 1
82 temp = line.split()
83 pack.append(temp)
84 valueflag=True
85 continue
86 if valueflag :
87 if line=='\n' :
88 valueflag=False
89 continue
90 else :
91 temp =line.strip()
92 pack[j].append(temp)
93 return pack
94 # repack return list [[levels], [level1, [PACKEGE1,module1,module2,...], [PACKEGE2,module1,module2], ..],[level2,[],[],...] ...]
95 def repack(self,pack):
96 listlen = len(pack)
97 pack2 = [['Levels']]
98 countpack = 0
99 for i in range(1,listlen):
100 packname = [[str(i)]]
101 check = 1
102 for j in range(1,len(pack[i])):
103
104 m = re.search('/',pack[i][j])
105 per = m.span()
106 title = pack[i][j][0:per[0]]
107 module = pack[i][j][per[1]:]
108 if j==1:
109 temp = []
110 temp.append(title)
111 packname.append(temp)
112 packname[check].append(module)
113 else:
114 if packname[check][0]==title:
115 packname[check].append(module)
116 else:
117 check = check + 1
118 temp = []
119 temp.append(title)
120 packname.append(temp)
121 packname[check].append(module)
122
123 pack2.append(packname)
124 return pack2
125
126 def dropdown(self,list):
127 self.page.write('\n<div id="test">\n\n')
128 listlen = len(list)
129 for level in range(1,listlen):
130 self.page.write(' * !'+str(list[level][0][0])+'\n')
131 for pack in range(1,len(list[level])):
132 self.page.write(' * !'+str(list[level][pack][0])+'\n')
133 for module in range(1,len(list[level][pack])):
134 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')
135 self.page.write('</div>\n%INCLUDE{"Main.DropDownMenu" section="js" MENU_ID="test"}%\n<br><br>\n\n')
136
137
138
139 if __name__=="__main__" :
140 from makeDepMetrics import mkDepMetrics
141 mkDM = mkDepMetrics('t','slc4_ia32_gcc345','CMSSW_3_1_X_2009-08-05-1200')
142 pkglist = mkDM.packlist()
143 outputlist = mkDM.repack(pkglist)
144 mkDM.dropdown(outputlist)
145