ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/TWikiIB/makeDepMetrics.py
(Generate patch)

Comparing UserCode/TWikiIB/makeDepMetrics.py (file contents):
Revision 1.1 by geonmo, Mon Sep 7 09:46:41 2009 UTC vs.
Revision 1.4 by geonmo, Mon Sep 7 23:30:21 2009 UTC

# Line 2 | Line 2
2   import re, os
3  
4   class mkDepMetrics(object) :
5 <        def __init__(self, page, tday, arch, package_name) :
5 >        def __init__(self, page, tday, arch, packagename) :
6                  self.page=page
7                  self.tday = tday
8                  self.arch = arch
9 <                self.package_name = package_name
10 <                self.url = 'https://macms01.cern.ch/ap/ignominy/'+arch+'/'+package_name+'/igRun/metrics'
11 <                self.contents = os.popen('wget --no-check-certificate -nv -o /dev/null -O- '+self.url)
12 <
13 <                self.page.write("""
14 < <!--
15 <   * Set MENU_ID = test
16 < -->
17 <
18 < <style> /* <pre> */
19 < %STARTSECTION{"css"}%
20 <
21 < #%MENU_ID% ul{
22 <  margin: 0px;
23 <  pading: 0px;
24 < }
25 <
26 < #%MENU_ID% ul li{
27 <  position:relative;    
28 <  list-style: none;
29 <  margin: 0px 0px 0px 15px;
30 <  float: left;
31 <  font-family: sans-serif;
32 <  font-weight: 800;
33 <  font-size: 12px;
34 < }
35 <
36 < #%MENU_ID% ul ul li{
37 <  position:relative;    
38 <  font-weight: 500;
39 <  float: none;
40 <  margin: 0px 0px 0px -40px;
41 <  pading: 0px;
42 <  border: none;
43 <  background-color: none;
44 <  border-top: 1px solid #F8F8F8;
45 <  border-bottom: 1px solid #C0C0C0;
46 < }
47 < #%MENU_ID%.msie ul ul li{
48 <  position:relative;    
49 <  margin-left: 0px;
50 < }
51 <
52 < #%MENU_ID% ul ul{
53 <  margin: 0px;
54 <  clear: left;
55 <  display: none;
56 <  position: absolute;
57 <  top: 20px;
58 <  left: 0px;
59 <  background-color: #E0E0E0;
60 <  border: 1px solid #808080;
61 <  width: 150px;
62 <  z-index:30;
63 < }
64 < #%MENU_ID%.msie ul ul{
65 <  width: 180px;
66 < }
67 <
68 < #%MENU_ID% ul ul ul{
69 <  top: 5px;
70 <  left: 190px;
71 < }
72 <
73 < #%MENU_ID% a:link,
74 < #%MENU_ID% a:active,
75 < #%MENU_ID% a:visited{
76 <  text-decoration: none;
77 <  color: #0E0E0E;
78 <  overflow: hidden;
79 < }
80 <
81 < #%MENU_ID% ul ul a{
82 <  padding: 0px 2px 0px 5px;
83 <  display: block;
84 <  background-color: #DCDCDC;
85 <  z-index:20;
86 < }
87 <
88 < #%MENU_ID% ul ul a:hover{
89 <  background-color: #0EEEEE;
90 < }
91 <
92 < #%MENU_ID% ul ul a.linkSubMenu:link,
93 < #%MENU_ID% ul ul a.linkSubMenu:active,
94 < #%MENU_ID% ul ul a.linkSubMenu:visited{
95 <  font-weight: 800;
96 < }
97 < %ENDSECTION{"css"}%
98 < /* </pre> */ </style>
99 < """)
100 <    
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 >                    break
29 >                elif line=='\n' :
30 >                    continue
31 >                elif line[0:5] =='* CCD' :
32 >                    writeflag = False
33 >                    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 >                    continue
58                  
59  
60          def packlist(self):
61 <                contents=self.contents  
62 <                pack = [['Levels']]
63 <                j=0
64 <                while 1:
65 <                        l = contents.readline()
66 <                        if not l:
67 <                                    if j==0 : self.page.write('---+++++No data about metrics information.\n')
111 <                                    break
112 <                        m1 = re.search('# Levels',l)
113 <                        if m1:
114 <                                while 1:
115 <                                        l2 = contents.readline()
116 <                                        if not l2:
117 <                                            break
118 <                                        if l2=='\n':
119 <                                            continue
120 <                                        m2 = re.search('[0-9]. ',l2)
121 <                                        if m2:
122 <                                            j = j + 1
123 <                                            temp = l2.split()
124 <                                            pack.append(temp)
125 <                                        
126 <                                            while 1:
127 <                                                l3 = contents.readline()
128 <                                                if l3=='\n':
129 <                                                    break
130 <                                                if not l3:
131 <                                                    break
132 <                                                temp =l3.split()
133 <                                                pack[j].extend(temp)
134 <            
61 >            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 +                    print line
73 +                    continue
74 +                elif not writeflag :
75 +                    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 +                        print temp
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 +            #print pack
97              listlen = len(pack)
98              pack2 = [['Levels']]
99              countpack = 0
# Line 168 | Line 127 | class mkDepMetrics(object) :
127              return pack2
128              
129          def dropdown(self,list):
130 <            self.page.write('<div id="test">\n\n')    
130 >            self.page.write('\n<div id="test">\n\n')    
131              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 <                        self.page.write('         * [[https://macms01.cern.ch/ap/ignominy/'+self.arch+'/'+self.package_name+'/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')
137 >                        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              self.page.write('</div>\n%INCLUDE{"Main.DropDownMenu" section="js" MENU_ID="test"}%\n<br><br>\n\n')
139  
140                    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines