3 from __future__
import print_function
4 from builtins
import range
6 __date__ =
"$2010-08-12 10.50.40$" 8 from optparse
import OptionParser
9 from shutil
import rmtree
10 from os.path
import join
13 from Utilities.ReleaseScripts.cmsCodeRules.Formatter
import SimpleHTMLFormatter
14 from Utilities.ReleaseScripts.cmsCodeRules.pickleFileParser
import readPicFiles
15 from Utilities.ReleaseScripts.cmsCodeRules.config
import rulesNames, ordering, Configuration, htmlPath, checkPath
23 dirs = os.path.abspath(pathIn).
split(
'/')
25 if item.startswith(
'CMSSW_'):
31 fooYr, m, d, hr = ib.split(
'-')
32 wkDay = datetime.date(
int(fooYr[-4:]),
int(m),
int(d) ).strftime(
"%a")
38 def __init__(self, formatter, pickleDir, logsDir, htmlDir):
53 ib, wkDay =
getIB(checkPath)
59 self.
formatter.writeH2(
"CMSSW code rules violation for "+ib)
61 self.
formatter.startTable([20,20,20,20,50],
62 [
'Rule',
'Packages',
'Files',
'Sum of violations',
'Description'], id =
63 'descriptionTable', tableAttr=
'border="0" cellspacing="5" cellpadding="5"')
65 for ruleName
in rulesNames:
67 ruleRes = rulesResults[ruleName]
70 for package, packageResult
in ruleRes:
71 totalFiles += len(packageResult)
72 for file, lines
in packageResult:
73 totalViolations += len(lines)
75 str(totalFiles),
str(totalViolations),
78 self.
formatter.writeRow([ruleName,
'-',
'-',
'-',
84 Click on the package links to get list of files 96 colLab.append(
'Rule %s' %rule)
98 self.
formatter.startTable(colFmt, colLab, id =
'mainTable', cls=
'display', tableAttr=
'border="0" cellspacing="5" cellpadding="5"')
102 tableRow = len(colLab)*
tuple(
'')
104 for ruleName
in rules:
106 ruleResult = rulesResults[ruleName]
107 for package, packageResult
in ruleResult:
109 index = packages.index(package)
110 tableRow = table[index] +(
str(len(packageResult)),)
111 table[index] = tableRow
113 packages.append(package)
114 tableRow = (
'<a href="logs/'+package+
'/log.html"/>'+package,) +
tuple(
'-' for i
in range(ruleNr)) + (
str(len(packageResult)),)
115 table.append(tableRow)
129 for index, tableRow
in enumerate(table):
130 if len(tableRow)-1 != ruleNr + 1:
131 table[index] = table[index] + (
'-',)
137 number = (3-length)*
str(0) + number
141 logDir =
join(logsDir,
"logs")
142 if os.path.exists(logDir):
144 for ruleName
in rulesNames:
146 ruleResult = rulesResult[ruleName]
147 for package, packageResult
in ruleResult:
148 logsDir =
join(logDir, package)
149 if not os.path.exists(logsDir): os.makedirs(logsDir, 0o755)
150 file = open(
join(logsDir,
"log.html"),
'a')
151 file.write(
'Rule %s'%ruleName)
153 for path, lineNumbers
in packageResult:
154 for line
in lineNumbers:
155 directory =
join(package, path)
156 file.write(
'<a href="https://cmssdt.cern.ch/lxr/source/%s?v=%s#%s">%s:%s</a>\n'%(directory, ib,
numberConverter(line), directory, line))
163 def run(pickleDir, logsDir, htmlDir):
165 for i
in range(len(ordering)):
166 aoSorting +=
"["+
str(i+1) +
",'desc']," 167 aoSorting +=
"[0, 'asc']" 171 <style type="text/css" title="currentStyle"> 172 @import "/SDT/html/jsExt/dataTables/media/css/demo_table.css"; 175 <script type="text/javascript" src="/SDT/html/jsExt/dataTables/media/js/jquery.js"></script> 176 <script type="text/javascript" src="/SDT/html/jsExt/dataTables/media/js/jquery.dataTables.js"></script> 178 <script type="text/javascript" charset="utf-8"> 179 /* Initialise the table with the required column sorting data types */ 180 $(document).ready(function() { 181 $('#mainTable').dataTable( { 183 "sLengthMenu": "Display _MENU_ records per page", 184 "sInfoEmpty": "Showing 0 to 0 of 0 records" 188 $('#descriptionTable').dataTable( { 189 "aaSorting": [[0, 'asc']], 191 "bLengthChange": false, 197 $('#descriptionTable thead th').css({'border-bottom': '1px solid black'}); 202 fmtr = SimpleHTMLFormatter(title=
"CMSSW integration builds", style=style, outFile = open(
join(htmlDir,
"cmsCRPage.html"),
"w"))
204 bv =
BuildViewer(fmtr, pickleDir, logsDir, htmlDir)
209 parser = OptionParser()
210 parser.add_option(
"-l",
"-L", dest=
"logDir", help =
"creates log files to DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
211 parser.add_option(
"-p",
"-P", dest=
"pickleDir", help =
"reads pickle files from DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
212 parser.add_option(
"-c",
"-C", dest=
"htmlDir", help =
"creates cmsCRPage.html file to DIRECTORY", metavar =
"DIRECTORY", default = os.getcwd())
213 (options, args) = parser.parse_args()
215 logsDir = options.logDir
216 pickleDir = options.pickleDir
217 htmlDir = options.htmlDir
219 if not os.path.exists(logsDir):
220 print(
"Error: wrong directory %s"%logsDir)
223 if not os.path.exists(pickleDir):
224 print(
"Error: wrong directory %s"%pickleDir)
227 if not os.path.exists(htmlDir):
228 print(
"Error: wrong directory %s"%htmlDir)
231 run(pickleDir, logsDir, htmlDir)
235 if __name__ ==
"__main__":
def addDash(table, ruleNr)
def createLogFiles(rulesResult, logsDir, ib)
def __init__(self, formatter, pickleDir, logsDir, htmlDir)
def run(pickleDir, logsDir, htmlDir)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def numberConverter(number)
def split(sequence, size)
static std::string join(char **cmd)
def readPicFiles(directory, toSplit=False)