+# try:
+# imgs = [img for img in dircache.listdir(thumb)]
+# except OSError:
+# imgs = [ self.name + ".png" ]
+ imgs = [ 'tgraph.png' ]
+ for img in imgs:
+ print >>file, "<a href='%s/results.html'><img src='%s/%s'></a>" % \
+ (urllib.quote(self.path), urllib.quote(self.path), img)
+ def fullImgLink(self, pngName):
+ if os.environ['NO_PDF']:
+ return "<div><img src='%s' /></div>" % pngName
+ else:
+ return "<div><a href='%s'><img src='%s' /></a></div>" % \
+ (pngName[:-4]+".pdf", pngName)
+
+ def htmlPrintStats(self, html):
+ cwd = os.getcwd()
+ os.chdir(self.path)
+ stats = glob.glob("*-stat.txt")
+ print >>html, "<h3>Statistics</h3>"
+ print >>html, "<table><tr>"
+ stats.sort()
+ for i in stats:
+ lines = open(i).readlines()
+ def fixupLine(l):
+ comment = l.find("#")
+ if comment >= 0:
+ l = l[:comment-1]
+ if l.find("cmdline=") == 0:
+ l = "<abbr title=%s>cmdline=...</abbr>" % str(l[8:])
+ return l
+ lines = [fixupLine(l) for l in lines]
+ print >>html, "<td><h4>%s</h4>%s</td>" % (i, "<br />".join(lines))
+ print >>html, "</tr></table>"
+ os.chdir(cwd)
+
+ def generateHtml(self):
+ html = open(os.path.join(self.path, 'results.html'), "w")
+ title = "CAN gateway timing analysis"
+ cdup = "../"*len(self.values)
+ print >> html, """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>%s</title>
+<link rel="stylesheet" href="%sstyle.css" type="text/css" />
+</head>
+<body>
+<h1>%s</h1>""" % (title, cdup, title)
+ params = ["%s %s" % (v.dim, v) for v in self.values]
+ print >>html, "Results for:", ", ".join(params)
+ print >>html, "<div class='otherview'><h4>Other results</h4><table>"
+ for d in self.tests.space:
+ links = []
+ for v in d:
+ if v in self.values:
+ links.append("<span class='value current'>%s</span>"%str(v))
+ else:
+ vv = DimValues(self.values)
+ vv.replace(v)
+ try:
+ href = cdup + urllib.quote(self.tests[vv.key()].path+"/results.html")
+ links.append("<span class='value other'><a href='%s'>%s</a></span>"%(href, str(v)))
+ except KeyError:
+ links.append("<span class='value missing'>%s</span>"%str(v))
+ print >>html, "<tr><th>%s</th><td>" % d, " ".join(links), "</td></tr>"
+
+ print >>html, "</table></div>"
+ print >>html, self.fullImgLink("graph.png")
+ self.htmlPrintStats(html)
+ cwd = os.getcwd()
+ os.chdir(self.path)
+ additionalImgs = glob.glob("graph?*.png")
+ if additionalImgs: print >>html, "<h3>Additional graphs</h3>"
+ for i in additionalImgs:
+ print >>html, "<h4>%s</h4>" % i[5:-4]
+ print >>html, self.fullImgLink(i)
+ os.chdir(cwd)
+
+ print >>html, "<hr />"
+ print >>html, "<a href='./'>Raw data</a><br />"
+ print >>html, "<a href='%s'>Script source</a><br />" % (cdup+self.name+".sh.html")
+ print >>html, "<a href='%s'>Back to top</a><br />" % cdup
+
+ html.close()
+
+class Space(list):
+ """List of Dimensions()s (order matters)"""
+ def __init__(self, *dimensions):
+ self.extend(list(dimensions))
+ def path2dimValues(self, path):
+ coordinates = path.split("/")
+ if len(coordinates) != len(self):
+ raise KeyError("The number coordinates do not match the number of dimensions: " + str(coordinates))
+
+ dv = DimValues([DimValue(self[i], coordinates[i]) \
+ for i in xrange(len(coordinates))])
+ return dv
+
+ def iterValues(self):
+ idx = [0 for i in xrange(len(self))]
+ done=False
+ while not done:
+ values=DimValues()
+ for i in xrange(len(self)):
+ values.append(self[i].values()[idx[i]])
+ yield values
+ done=True
+ for i in xrange(len(self)):
+ idx[i] += 1
+ if idx[i] < len(self[i]):
+ done=False
+ break
+ idx[i] = 0
+ def reorder(self, dimValues):
+ reordered = DimValues()
+ for d in self:
+ for v in dimValues:
+ if v.dim == d:
+ reordered.append(v)
+ return reordered
+ def iterDimensionPairs(self):
+ for i in xrange(len(self)):
+ for j in xrange(i+1, len(self)):
+ yield (self[i], self[j])
+ yield (self[j], self[i])
+ def iterRemainingDimensions(self, dimensionPair):
+ for d in self:
+ if d not in dimensionPair:
+ yield d
+