19744: Include text report in HTML report
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 9 Feb 2024 23:23:36 +0000 (18:23 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 9 Feb 2024 23:23:36 +0000 (18:23 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

tools/crunchstat-summary/crunchstat_summary/summarizer.py
tools/crunchstat-summary/crunchstat_summary/webchart.py

index 2bd329719bec70300d268b06bb6abe8e3abf245c..79573606171b9b3fcca79c9b4cfeaff42d5d7152 100644 (file)
@@ -632,7 +632,17 @@ class MultiSummarizer(object):
         return d
 
     def html_report(self):
-        return WEBCHART_CLASS(self.label, iter(self._descendants().values())).html()
+        txt = self.text_report()
+        fmt = """
+        <table>
+        <tbody>
+        {}
+        </tbody>
+        </table>
+        <p>{}</p>
+        """.format("\n".join("<tr><td>{}</td></tr>".format(x.replace("\t", "</td><td>")) for x in txt.split("\n") if not x.startswith("#")),
+                   "\n".join("{}<br>".format(x) for x in txt.split("\n") if x.startswith("#")))
+        return WEBCHART_CLASS(self.label, iter(self._descendants().values())).html(fmt)
 
 
 class JobTreeSummarizer(MultiSummarizer):
index 31afcf64e906166788bf06b9caa4ed191ead13c9..8adf0fee7eda9c157bd32562cf88e573afea7bf3 100644 (file)
@@ -24,15 +24,24 @@ class WebChart(object):
         self.label = label
         self.summarizers = summarizers
 
-    def html(self):
+    def html(self, bodytext=''):
         return '''<!doctype html><html><head>
         <title>{} stats</title>
         <script type="text/javascript" src="{}"></script>
         <script type="text/javascript">{}</script>
+        <style>
+        table {{
+          width: 80%
+        }}
+        td {{
+          width: 20%;
+        }}
+        </style>
         {}
-        </head><body></body></html>
+        </head><body>{}</body></html>
         '''.format(escape(self.label),
-                   self.JSLIB, self.js(), self.headHTML())
+                   self.JSLIB, self.js(), self.headHTML(),
+                   bodytext)
 
     def js(self):
         return 'var chartdata = {};\n{}'.format(