3 from __future__
import print_function
5 __date__ =
"$2010-08-12 10.50.40$" 7 from optparse
import OptionParser
8 from shutil
import rmtree
9 from os.path
import join
12 from Utilities.ReleaseScripts.cmsCodeRules.Formatter
import SimpleHTMLFormatter
13 from Utilities.ReleaseScripts.cmsCodeRules.pickleFileParser
import readPicFiles
14 from Utilities.ReleaseScripts.cmsCodeRules.config
import rulesNames, ordering, Configuration, htmlPath, checkPath
22 dirs = os.path.abspath(pathIn).
split(
'/')
24 if item.startswith(
'CMSSW_'):
30 fooYr, m, d, hr = ib.split(
'-')
31 wkDay = datetime.date(
int(fooYr[-4:]),
int(m),
int(d) ).strftime(
"%a")
37 def __init__(self, formatter, pickleDir, logsDir, htmlDir):
52 ib, wkDay =
getIB(checkPath)
57 self.formatter.writeAnchor(ref=
'top')
58 self.formatter.writeH2(
"CMSSW code rules violation for "+ib)
60 self.formatter.startTable([20,20,20,20,50],
61 [
'Rule',
'Packages',
'Files',
'Sum of violations',
'Description'], id =
62 'descriptionTable', tableAttr=
'border="0" cellspacing="5" cellpadding="5"')
64 for ruleName
in rulesNames:
66 ruleRes = rulesResults[ruleName]
69 for package, packageResult
in ruleRes:
70 totalFiles += len(packageResult)
71 for file, lines
in packageResult:
72 totalViolations += len(lines)
73 self.formatter.writeRow([ruleName,
str(len(ruleRes)),
74 str(totalFiles),
str(totalViolations),
77 self.formatter.writeRow([ruleName,
'-',
'-',
'-',
79 self.formatter.endTable()
83 Click on the package links to get list of files 87 self.formatter.write(msg)
95 colLab.append(
'Rule %s' %rule)
97 self.formatter.startTable(colFmt, colLab, id =
'mainTable', cls=
'display', tableAttr=
'border="0" cellspacing="5" cellpadding="5"')
101 tableRow = len(colLab)*tuple(
'')
103 for ruleName
in rules:
105 ruleResult = rulesResults[ruleName]
106 for package, packageResult
in ruleResult:
108 index = packages.index(package)
109 tableRow = table[index] +(
str(len(packageResult)),)
110 table[index] = tableRow
112 packages.append(package)
113 tableRow = (
'<a href="logs/'+package+
'/log.html"/>'+package,) + tuple(
'-' for i
in range(ruleNr)) + (
str(len(packageResult)),)
114 table.append(tableRow)
121 self.formatter.writeRow(row)
123 self.formatter.endTable()
128 for index, tableRow
in enumerate(table):
129 if len(tableRow)-1 != ruleNr + 1:
130 table[index] = table[index] + (
'-',)
136 number = (3-length)*
str(0) + number
140 logDir =
join(logsDir,
"logs")
141 if os.path.exists(logDir):
143 for ruleName
in rulesNames:
145 ruleResult = rulesResult[ruleName]
146 for package, packageResult
in ruleResult:
147 logsDir =
join(logDir, package)
148 if not os.path.exists(logsDir): os.makedirs(logsDir, 0o755)
149 file = open(
join(logsDir,
"log.html"),
'a')
150 file.write(
'Rule %s'%ruleName)
152 for path, lineNumbers
in packageResult:
153 for line
in lineNumbers:
154 directory =
join(package, path)
155 file.write(
'<a href="http://cmslxr.fnal.gov/lxr/source/%s?v=%s#%s">%s:%s</a>\n'%(directory, ib,
numberConverter(line), directory, line))
162 def run(pickleDir, logsDir, htmlDir):
164 for i
in range(len(ordering)):
165 aoSorting +=
"["+
str(i+1) +
",'desc']," 166 aoSorting +=
"[0, 'asc']" 170 <style type="text/css" title="currentStyle"> 171 @import "/SDT/html/jsExt/dataTables/media/css/demo_table.css"; 174 <script type="text/javascript" src="/SDT/html/jsExt/dataTables/media/js/jquery.js"></script> 175 <script type="text/javascript" src="/SDT/html/jsExt/dataTables/media/js/jquery.dataTables.js"></script> 177 <script type="text/javascript" charset="utf-8"> 178 /* Initialise the table with the required column sorting data types */ 179 $(document).ready(function() { 180 $('#mainTable').dataTable( { 182 "sLengthMenu": "Display _MENU_ records per page", 183 "sInfoEmpty": "Showing 0 to 0 of 0 records" 187 $('#descriptionTable').dataTable( { 188 "aaSorting": [[0, 'asc']], 190 "bLengthChange": false, 196 $('#descriptionTable thead th').css({'border-bottom': '1px solid black'}); 201 fmtr = SimpleHTMLFormatter(title=
"CMSSW integration builds", style=style, outFile = open(
join(htmlDir,
"cmsCRPage.html"),
"w"))
203 bv =
BuildViewer(fmtr, pickleDir, logsDir, htmlDir)
208 parser = OptionParser()
209 parser.add_option(
"-l",
"-L", dest=
"logDir", help =
"creates log files to DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
210 parser.add_option(
"-p",
"-P", dest=
"pickleDir", help =
"reads pickle files from DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
211 parser.add_option(
"-c",
"-C", dest=
"htmlDir", help =
"creates cmsCRPage.html file to DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
212 (options, args) = parser.parse_args()
214 logsDir = options.logDir
215 pickleDir = options.pickleDir
216 htmlDir = options.htmlDir
218 if not os.path.exists(logsDir):
219 print(
"Error: wrong directory %s"%logsDir)
222 if not os.path.exists(pickleDir):
223 print(
"Error: wrong directory %s"%pickleDir)
226 if not os.path.exists(htmlDir):
227 print(
"Error: wrong directory %s"%htmlDir)
230 run(pickleDir, logsDir, htmlDir)
234 if __name__ ==
"__main__":
def addDash(table, ruleNr)
def createLogFiles(rulesResult, logsDir, ib)
def __init__(self, formatter, pickleDir, logsDir, htmlDir)
S & print(S &os, JobReport::InputFile const &f)
def run(pickleDir, logsDir, htmlDir)
def numberConverter(number)
static std::string join(char **cmd)
def readPicFiles(directory, toSplit=False)