4 __date__ =
"$2010-08-12 10.50.40$"
6 from optparse
import OptionParser
7 from shutil
import rmtree
8 from os.path
import join
11 from Utilities.ReleaseScripts.cmsCodeRules.Formatter
import SimpleHTMLFormatter
12 from Utilities.ReleaseScripts.cmsCodeRules.pickleFileParser
import readPicFiles
13 from Utilities.ReleaseScripts.cmsCodeRules.config
import rulesNames, ordering, Configuration, htmlPath, checkPath
21 dirs = os.path.abspath(pathIn).
split(
'/')
23 if item.startswith(
'CMSSW_'):
29 fooYr, m, d, hr = ib.split(
'-')
30 wkDay = datetime.date( int(fooYr[-4:]), int(m), int(d) ).strftime(
"%a")
36 def __init__(self, formatter, pickleDir, logsDir, htmlDir):
51 ib, wkDay =
getIB(checkPath)
56 self.formatter.writeAnchor(ref=
'top')
57 self.formatter.writeH2(
"CMSSW code rules violation for "+ib)
59 self.formatter.startTable([20,20,20,20,50],
60 [
'Rule',
'Packages',
'Files',
'Sum of violations',
'Description'], id =
61 'descriptionTable', tableAttr=
'border="0" cellspacing="5" cellpadding="5"')
63 for ruleName
in rulesNames:
65 ruleRes = rulesResults[ruleName]
68 for package, packageResult
in ruleRes:
69 totalFiles += len(packageResult)
70 for file, lines
in packageResult:
71 totalViolations += len(lines)
72 self.formatter.writeRow([ruleName,str(len(ruleRes)),
73 str(totalFiles), str(totalViolations),
76 self.formatter.writeRow([ruleName,
'-',
'-',
'-',
78 self.formatter.endTable()
82 Click on the package links to get list of files
86 self.formatter.write(msg)
94 colLab.append(
'Rule %s' %rule)
96 self.formatter.startTable(colFmt, colLab, id =
'mainTable', cls=
'display', tableAttr=
'border="0" cellspacing="5" cellpadding="5"')
100 tableRow = len(colLab)*tuple(
'')
102 for ruleName
in rules:
104 ruleResult = rulesResults[ruleName]
105 for package, packageResult
in ruleResult:
107 index = packages.index(package)
108 tableRow = table[index] +(str(len(packageResult)),)
109 table[index] = tableRow
111 packages.append(package)
112 tableRow = (
'<a href="logs/'+package+
'/log.html"/>'+package,) + tuple(
'-' for i
in range(ruleNr)) + (str(len(packageResult)),)
113 table.append(tableRow)
120 self.formatter.writeRow(row)
122 self.formatter.endTable()
127 for index, tableRow
in enumerate(table):
128 if len(tableRow)-1 != ruleNr + 1:
129 table[index] = table[index] + (
'-',)
135 number = (3-length)*str(0) + number
139 logDir =
join(logsDir,
"logs")
140 if os.path.exists(logDir):
142 for ruleName
in rulesNames:
144 ruleResult = rulesResult[ruleName]
145 for package, packageResult
in ruleResult:
146 logsDir =
join(logDir, package)
147 if not os.path.exists(logsDir): os.makedirs(logsDir, 0o755)
148 file = open(
join(logsDir,
"log.html"),
'a')
149 file.write(
'Rule %s'%ruleName)
151 for path, lineNumbers
in packageResult:
152 for line
in lineNumbers:
153 directory =
join(package, path)
154 file.write(
'<a href="http://cmslxr.fnal.gov/lxr/source/%s?v=%s#%s">%s:%s</a>\n'%(directory, ib,
numberConverter(line), directory, line))
161 def run(pickleDir, logsDir, htmlDir):
163 for i
in range(len(ordering)):
164 aoSorting +=
"["+ str(i+1) +
",'desc'],"
165 aoSorting +=
"[0, 'asc']"
169 <style type="text/css" title="currentStyle">
170 @import "/SDT/html/jsExt/dataTables/media/css/demo_table.css";
173 <script type="text/javascript" src="/SDT/html/jsExt/dataTables/media/js/jquery.js"></script>
174 <script type="text/javascript" src="/SDT/html/jsExt/dataTables/media/js/jquery.dataTables.js"></script>
176 <script type="text/javascript" charset="utf-8">
177 /* Initialise the table with the required column sorting data types */
178 $(document).ready(function() {
179 $('#mainTable').dataTable( {
181 "sLengthMenu": "Display _MENU_ records per page",
182 "sInfoEmpty": "Showing 0 to 0 of 0 records"
186 $('#descriptionTable').dataTable( {
187 "aaSorting": [[0, 'asc']],
189 "bLengthChange": false,
195 $('#descriptionTable thead th').css({'border-bottom': '1px solid black'});
200 fmtr = SimpleHTMLFormatter(title=
"CMSSW integration builds", style=style, outFile = open(
join(htmlDir,
"cmsCRPage.html"),
"w"))
202 bv =
BuildViewer(fmtr, pickleDir, logsDir, htmlDir)
207 parser = OptionParser()
208 parser.add_option(
"-l",
"-L", dest=
"logDir", help =
"creates log files to DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
209 parser.add_option(
"-p",
"-P", dest=
"pickleDir", help =
"reads pickle files from DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
210 parser.add_option(
"-c",
"-C", dest=
"htmlDir", help =
"creates cmsCRPage.html file to DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
211 (options, args) = parser.parse_args()
213 logsDir = options.logDir
214 pickleDir = options.pickleDir
215 htmlDir = options.htmlDir
217 if not os.path.exists(logsDir):
218 print "Error: wrong directory %s"%logsDir
221 if not os.path.exists(pickleDir):
222 print "Error: wrong directory %s"%pickleDir
225 if not os.path.exists(htmlDir):
226 print "Error: wrong directory %s"%htmlDir
229 run(pickleDir, logsDir, htmlDir)
233 if __name__ ==
"__main__":
static std::string join(char **cmd)