2013-10-16 18:15:51 +02:00
import os
import sys
2013-11-27 19:17:22 +01:00
import subprocess
2013-10-16 18:15:51 +02:00
2013-10-18 17:35:59 +02:00
2013-10-16 18:15:51 +02:00
def readdate ( data ) :
2013-10-18 17:35:59 +02:00
datepos = - 1
if data [ : 5 ] == ' DATE ' :
datepos = 0
else :
datepos = data . find ( ' \n DATE ' )
if datepos > = 0 :
datepos = datepos + 1
2013-10-16 18:15:51 +02:00
2013-10-18 17:35:59 +02:00
if datepos < 0 :
return None
2013-10-16 18:15:51 +02:00
2013-10-18 17:35:59 +02:00
datestr = ' '
datepos = datepos + 5
while True :
if datepos > = len ( data ) :
return None
d = data [ datepos ]
if d > = ' 0 ' and d < = ' 9 ' :
datestr = datestr + d
elif d == ' \n ' :
if len ( datestr ) == 8 :
return datestr [ : 4 ] + ' - ' + datestr [ 4 : 6 ] + ' - ' + datestr [ 6 : ]
return None
elif d != ' ' and d != ' - ' :
return None
datepos = datepos + 1
2013-10-16 18:15:51 +02:00
path = ' . '
if len ( sys . argv ) == 2 :
path = sys . argv [ 1 ]
mainpage = open ( path + ' /daca2.html ' , ' wt ' )
2013-10-17 15:20:58 +02:00
mainpage . write ( ' <!DOCTYPE html> \n ' )
2013-11-04 13:18:01 +01:00
mainpage . write ( ' <html lang= " en " > \n ' )
mainpage . write ( ' <head> \n ' )
2014-03-16 11:07:40 +01:00
mainpage . write ( ' <meta charset= " utf-8 " > \n ' )
2013-11-04 13:18:01 +01:00
mainpage . write ( ' <title>DACA2</title> \n ' )
2014-03-18 15:38:18 +01:00
mainpage . write ( ' <link rel= " stylesheet " href= " /site/css/daca2.css " > ' )
2014-03-16 16:58:48 +01:00
mainpage . write ( ' <script src= " /site/js/sorttable.min.js " ></script> \n ' )
2013-11-04 13:18:01 +01:00
mainpage . write ( ' </head> \n ' )
2013-10-16 18:15:51 +02:00
mainpage . write ( ' <body> \n ' )
mainpage . write ( ' <h1>DACA2</h1> \n ' )
2014-03-09 08:32:29 +01:00
mainpage . write ( ' <p>Results when running latest (git head) Cppcheck on Debian.</p> \n ' )
mainpage . write ( ' <p>For performance reasons the analysis is limited. Files larger than 100kb are skipped. If analysis of a file takes more than 10 minutes it may be stopped.</p> \n ' )
mainpage . write ( ' <table class= " sortable " > \n ' )
2013-11-04 13:18:01 +01:00
mainpage . write (
2013-11-24 10:47:12 +01:00
' <tr> ' +
2014-03-09 08:32:29 +01:00
' <th>Name</th> ' +
' <th>Date</th> ' +
' <th>Error</th> ' +
' <th>Warning</th> ' +
' <th>Performance</th> ' +
' <th>Portability</th> ' +
' <th>Style</th> ' +
2014-03-12 12:49:06 +01:00
' <th>Crashes</th> ' +
' <th>VarID 0</th></tr> \n ' )
2013-10-16 18:15:51 +02:00
lastupdate = None
recent = [ ]
daca2 = os . path . expanduser ( ' ~/daca2/ ' )
for lib in range ( 2 ) :
2013-10-18 17:35:59 +02:00
for a in " 0123456789abcdefghijklmnopqrstuvwxyz " :
if lib == 1 :
a = " lib " + a
if os . path . isfile ( daca2 + a + ' /results.txt ' ) :
f = open ( daca2 + a + ' /results.txt ' , ' rt ' )
data = f . read ( )
f . close ( )
2013-10-16 18:15:51 +02:00
2013-10-18 17:35:59 +02:00
datestr = readdate ( data )
2013-11-27 19:17:22 +01:00
if os . path . isfile ( daca2 + ' results- ' + a + ' .txt ' ) :
f2 = open ( daca2 + ' results- ' + a + ' .txt ' )
data2 = f2 . read ( )
f2 . close ( )
datestr2 = readdate ( data2 )
if not datestr or datestr < datestr2 :
data = data2
datestr = datestr2
2013-10-18 17:35:59 +02:00
if datestr :
if not lastupdate or datestr > lastupdate :
lastupdate = datestr
recent = [ ]
if datestr == lastupdate :
recent . append ( a )
2013-11-28 17:44:50 +01:00
else :
datestr = ' '
2013-10-16 18:15:51 +02:00
2013-10-18 17:35:59 +02:00
mainpage . write (
2013-11-24 10:47:12 +01:00
' <tr> ' +
' <td><a href= " daca2- ' + a + ' .html " > ' + a + ' </a></td> ' +
' <td> ' + datestr + ' </td> ' +
' <td> ' + str ( data . count ( ' (error) ' ) ) + ' </td> ' +
' <td> ' + str ( data . count ( ' (warning) ' ) ) + ' </td> ' +
' <td> ' + str ( data . count ( ' (performance) ' ) ) + ' </td> ' +
' <td> ' + str ( data . count ( ' (portability) ' ) ) + ' </td> ' +
' <td> ' + str ( data . count ( ' (style) ' ) ) + ' </td> ' +
2014-01-29 12:54:52 +01:00
' <td> ' + str ( data . count ( ' Crash? ' ) ) + ' </td> ' +
2014-03-12 12:49:06 +01:00
' <td> ' + str ( data . count ( ' with varid 0. ' ) ) + ' </td> ' +
2013-11-24 10:47:12 +01:00
' </tr> \n ' )
2013-10-16 18:15:51 +02:00
2013-11-04 13:18:01 +01:00
data = data . replace ( ' & ' , ' & ' )
2013-10-18 17:35:59 +02:00
data = data . replace ( ' < ' , ' < ' )
data = data . replace ( ' > ' , ' > ' )
data = data . replace ( ' \n ' , ' \n ' )
2013-10-16 18:15:51 +02:00
2013-10-18 17:35:59 +02:00
f = open ( path + ' /daca2- ' + a + ' .html ' , ' wt ' )
2013-10-17 15:20:58 +02:00
f . write ( ' <!DOCTYPE html> \n ' )
2013-11-10 14:43:07 +01:00
f . write ( ' <html lang= " en " > \n ' )
f . write ( ' <head> \n ' )
2014-03-16 11:07:40 +01:00
f . write ( ' <meta charset= " utf-8 " > \n ' )
2013-11-10 14:43:07 +01:00
f . write ( ' <title>DACA2 - ' + a + ' </title> \n ' )
f . write ( ' </head> \n ' )
2013-10-18 17:35:59 +02:00
f . write ( ' <body> \n ' )
f . write ( ' <h1>DACA2 - ' + a + ' </h1> ' )
f . write ( ' <pre> \n ' + data + ' </pre> \n ' )
f . write ( ' </body> \n ' )
f . write ( ' </html> \n ' )
f . close ( )
2013-10-16 18:15:51 +02:00
2013-11-04 13:18:01 +01:00
mainpage . write ( ' </table> \n ' )
2013-10-16 18:15:51 +02:00
if lastupdate :
2013-10-18 17:35:59 +02:00
mainpage . write ( ' <p>Last update: ' + lastupdate + ' </p> ' )
allrecent = ' '
for r in recent :
2013-12-15 12:33:06 +01:00
allrecent = allrecent + ' <a href= " daca2- ' + r + ' .html " > ' + r + ' </a> '
mainpage . write ( ' <p>Most recently updated: ' + allrecent + ' </p> ' )
2013-10-16 18:15:51 +02:00
mainpage . write ( ' </body> \n ' )
mainpage . write ( ' </html> \n ' )