ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/TWikiIB/makeDepMetrics.py
Revision: 1.12
Committed: Wed Sep 9 07:25:22 2009 UTC (15 years, 7 months ago) by geonmo
Content type: text/x-python
Branch: MAIN
Changes since 1.11: +1 -1 lines
Log Message:
*** empty log message ***

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.11 if len(contents)==0 :
22     self.page.write(' * No data about summary\n')
23 geonmo 1.3 for line in contents :
24 geonmo 1.4 matchCycle = typeCycle.search(line)
25 geonmo 1.3 if line=='# Summary\n' :
26 geonmo 1.12 self.page.write(' * Summary\n')
27 geonmo 1.3 writeflag = True
28 geonmo 1.4 elif line=='# Levels\n' :
29     writeflag = False
30     cycleflag = False
31 geonmo 1.5 self.page.write('</div>\n')
32 geonmo 1.7 self.page.write('''<br><pre>
33 geonmo 1.4 * CCD: Cumulative Component Dependency measures the cumulative testing cost
34     across the system.
35     * ACD: Average Component Dependency indicates the number of other packages
36     an average package depends on.
37     * NCCD: Normalised Cumulative Component Dependency measures how the structure
38     differs from a balanced binary tree of comparable size. If NCCD is one,
39     the structure resembles a binary tree; if much less than one, the
40     packages are mostly independent; if much greater than one, the system
41     is fairly strongly coupled. The only universal NCCD target is to
42     minimise for any given software system--a high value indicates a
43     strongly coupled system and less coupling is better.
44 geonmo 1.5 </pre>
45 geonmo 1.7 ''')
46     break
47     elif line=='\n' :
48     continue
49     elif line[0:5] =='* CCD' :
50     writeflag = False
51 geonmo 1.4 elif line=='# Cycles\n' :
52     self.page.write(' * Cycles\n\n')
53 geonmo 1.5 self.page.write('<div id="test">\n')
54 geonmo 1.4 cycleflag=True
55     elif matchCycle and cycleflag :
56 geonmo 1.7 self.page.write(' * '+matchCycle.group(1)+'\n')
57 geonmo 1.4 elif cycleflag :
58 geonmo 1.7 self.page.write(' * !'+line.strip()+'\n')
59 geonmo 1.4 elif writeflag :
60     self.page.write(' * '+line)
61     else :
62 geonmo 1.3 continue
63 geonmo 1.1
64    
65     def packlist(self):
66 geonmo 1.2 contents=self.contents
67     pack = [['Levels']]
68     j=0
69     writeflag = False
70     valueflag = False
71     if len(contents)==0 :
72 geonmo 1.11 self.page.write(' * No data about metrics information.\n')
73 geonmo 1.2 return pack
74     for line in contents :
75     if line =='# Levels\n' :
76     writeflag = True
77 geonmo 1.3 continue
78     elif not writeflag :
79 geonmo 1.2 continue
80     if line=='\n':
81     continue
82     matchLevel = re.search('[0-9]. ',line)
83     if matchLevel :
84     j = j + 1
85     temp = line.split()
86     pack.append(temp)
87     valueflag=True
88     continue
89     if valueflag :
90     if line=='\n' :
91     valueflag=False
92     continue
93     else :
94     temp =line.strip()
95 geonmo 1.3 pack[j].append(temp)
96 geonmo 1.2 return pack
97 geonmo 1.1 # repack return list [[levels], [level1, [PACKEGE1,module1,module2,...], [PACKEGE2,module1,module2], ..],[level2,[],[],...] ...]
98     def repack(self,pack):
99     listlen = len(pack)
100     pack2 = [['Levels']]
101     countpack = 0
102     for i in range(1,listlen):
103     packname = [[str(i)]]
104     check = 1
105     for j in range(1,len(pack[i])):
106    
107     m = re.search('/',pack[i][j])
108     per = m.span()
109     title = pack[i][j][0:per[0]]
110     module = pack[i][j][per[1]:]
111     if j==1:
112     temp = []
113     temp.append(title)
114     packname.append(temp)
115     packname[check].append(module)
116     else:
117     if packname[check][0]==title:
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