import time from os.path import join as pjoin, basename import benchconfig as cfg class HTMLreport: def __init__(self, fname, title="Benchmarks report", \ inputfile=pjoin(cfg.reportdir, basename(cfg.inputfile))): self.fname = fname self.content = """ Benchmarks report

""" self.content += title + "

" date = time.strftime('%Y-%m-%d, %I:%M %p') self.content += '

Generated on ' + date + '

' cpuinfo = file('/proc/cpuinfo', 'r').readlines() cpu = None for l in cpuinfo: if l[:10] == 'model name': cpu = l.split(':',1)[1].strip() if cpu: self.content += '

CPU: ' + cpu + '

' meminfo = file('/proc/meminfo', 'r').readlines() mem = None for l in meminfo: if l[:8] == 'MemTotal': mem = l.split(':',1)[1].strip() if mem: self.content += '

Total memory: ' + mem + '

' self.content += '
Input file: ' + \ '%s' % (basename(inputfile), cfg.inputfile) + \ '
%s
' % file(cfg.inputfile, 'r').read() self.content += '
Logs: %s
' \ % cfg.logdir def addFig(self, title, image, descr='', alt='', width=None): self.content += '
' self.content += '

' + title + '

' if descr.strip() != '': self.content += '

' + descr + '

' self.content += '
' self.content += '' self.content += '