import os import sys import subprocess def readdate(data): datepos = -1 if data[:5] == 'DATE ': datepos = 0 else: datepos = data.find('\nDATE ') if datepos >= 0: datepos = datepos + 1 if datepos < 0: return None 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 if os.path.isfile(os.path.expanduser('~/aws-debian.pem')): subprocess.call(['scp', '-i', os.path.expanduser('~/aws-debian.pem'), 'admin@ec2-54-201-59-232.us-west-2.compute.amazonaws.com:daca2/results-*.txt', os.path.expanduser('~/daca2/')]) path = '.' if len(sys.argv) == 2: path = sys.argv[1] mainpage = open(path + '/daca2.html', 'wt') mainpage.write('\n') mainpage.write('\n') mainpage.write('\n') mainpage.write('\n') mainpage.write('DACA2\n') mainpage.write( '\n') mainpage.write('\n') mainpage.write('\n') mainpage.write('

DACA2

\n') mainpage.write( '

Results when running latest (git head) Cppcheck on Debian.

\n') mainpage.write( '

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.

\n') mainpage.write('\n') mainpage.write( '' + '' + '' + '' + '' + '' + '' + '\n') lastupdate = None recent = [] daca2 = os.path.expanduser('~/daca2/') for lib in range(2): 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() datestr = readdate(data) 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 if datestr: if not lastupdate or datestr > lastupdate: lastupdate = datestr recent = [] if datestr == lastupdate: recent.append(a) else: datestr = '' mainpage.write( '' + '' + '' + '' + '' + '' + '' + '' + '\n') data = data.replace('&', '&') data = data.replace('<', '<') data = data.replace('>', '>') data = data.replace('\n', '\n') f = open(path + '/daca2-' + a + '.html', 'wt') f.write('\n') f.write('\n') f.write('\n') f.write('\n') f.write('DACA2 - ' + a + '\n') f.write('\n') f.write('\n') f.write('

DACA2 - ' + a + '

') f.write('
\n' + data + '
\n') f.write('\n') f.write('\n') f.close() mainpage.write('
NameDateErrorWarningPerformancePortabilityStyle
' + a + '' + datestr + '' + str(data.count('(error)')) + '' + str(data.count('(warning)')) + '' + str(data.count('(performance)')) + '' + str(data.count('(portability)')) + '' + str(data.count('(style)')) + '
\n') if lastupdate: mainpage.write('

Last update: ' + lastupdate + '

') allrecent = '' for r in recent: allrecent = allrecent + '' + r + '' mainpage.write('

Most recently updated: ' + allrecent + '

') mainpage.write('\n') mainpage.write('\n')