ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/TWikiIB/makeDepMetrics.py
Revision: 1.4
Committed: Mon Sep 7 23:30:21 2009 UTC (15 years, 7 months ago) by geonmo
Content type: text/x-python
Branch: MAIN
Changes since 1.3: +33 -7 lines
Log Message:
bugfix about summary

File Contents

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