]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - gw-tests/genhtml/genhtml.py
Adds automatic update of copyright notice.
[can-benchmark.git] / gw-tests / genhtml / genhtml.py
index b75bdc4f87d09962fae7a0e9b4645faad92f87a6..811b7359e6634b10a7487e3b423825d3793bd97f 100755 (executable)
@@ -6,6 +6,9 @@ import sys;
 import urllib
 import traceback
 import glob
+import datetime
+
+html_copyright = """<div style="font-size: small; color: gray; margin-top: 1em;">Authors: Michal Sojka, Pavel Píša, Copyright © 2010-%d Czech Technical University in Prague</div>""" % datetime.date.today().year
 
 class DimValue(object):
     def __new__(cls, dim, value):
@@ -23,6 +26,8 @@ class DimValue(object):
        return "DimValue(%s, %s)" % (repr(self.dim), repr(self.value))
     def htmlTableHeading(self):
        return self.dim.htmlTableHeading(self.value)
+    def index(self):
+        return self.dim.sortedKeys.index(self.value)
 
 class DimValues(list):
     def replace(self, val):
@@ -152,8 +157,12 @@ class Test(object):
             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):
-        return "<div><a href='%s'><img src='%s' /></a></div>" % \
-               (pngName[:-4]+".pdf", pngName)
+        ps = "<a href='%s'>Plot source</a>" % ("plot"+pngName[5:-4]+".gp")
+        if 'NO_PDF' in os.environ:
+            return "<div><img src='%s' />%s</div>" % (pngName, ps)
+        else:
+            return "<div><a href='%s'><img src='%s' /></a>%s</div>" % \
+                   (pngName[:-4]+".pdf", pngName, ps)
         
     def htmlPrintStats(self, html):
         cwd = os.getcwd()
@@ -169,9 +178,7 @@ class Test(object):
                 if comment >= 0:
                     l = l[:comment-1]
                 if l.find("cmdline=") == 0:
-                    print l
                     l = "<abbr title=%s>cmdline=...</abbr>" % str(l[8:])
-                    print l
                 return l
             lines = [fixupLine(l) for l in lines]
             print >>html, "<td><h4>%s</h4>%s</td>" % (i, "<br />".join(lines))
@@ -217,6 +224,7 @@ class Test(object):
         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)
         
@@ -224,7 +232,7 @@ class Test(object):
         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
-
+        print >>html,"%s</body></html>" % html_copyright
         html.close()
 
 class Space(list):
@@ -320,6 +328,7 @@ h4 { margin: 0; }
 .otherview .other:hover { background: #eee; }
 .otherview .missing { color: gray; }
 .otherview .current { background: #ccc; }
+.na { width: 150px; height: 109px; display:  table-cell; text-align: center; vertical-align: middle; }
 """
         css.close()
         for test in self.values():
@@ -336,7 +345,7 @@ class Page(object):
        self.tests = tests
     def getName(self):
        return "%s-vs-%s-for-%s.html"%(self.dimy.type, self.dimx.type,
-                                       "-".join([v.value for v in self.valsOther]))
+                                       "-".join(["%02d"%v.index() for v in self.valsOther]))
     def generate(self):
        html = open(self.getName(), "w")
        title = "CAN gateway timing analysis" 
@@ -387,14 +396,14 @@ class Page(object):
                     test = tests.getTest(idx)
                     test.printThumbLink(html)
                 except KeyError:
-                    print >>html, "N/A"
+                    print >>html, "<span class='na'>N/A</span>"
                 print >>html, "</td>"
            print >>html, "</tr>"
        print >> html, """
 </table>
-<div style="font-size: small; color: gray; margin-top: 1em;">Authors: Michal Sojka, Pavel Píša, Copyright © 2010 Czech Technical University in Prague</div>
+%s
 </body>
-"""
+""" % html_copyright
 
 
 if __name__ == "__main__":