[LNT] r264525 - [ui] Add special rendering for the "producer" run property

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 26 16:01:28 PDT 2016


Author: jamesm
Date: Sat Mar 26 18:01:28 2016
New Revision: 264525

URL: http://llvm.org/viewvc/llvm-project?rev=264525&view=rev
Log:
[ui] Add special rendering for the "producer" run property

If a test run sets the run info property "producer", display it in the run comparison page in the top table.

It doesn't matter what this property is set to; it's intended to be used to indicate the "provenance" of a run - what ran it and why - like a buildbot build URL or jenkins URL.

Altough there's no required format, add special handling or strings that look like buildbot URLs or URLs in general.

Modified:
    lnt/trunk/lnt/server/ui/filters.py
    lnt/trunk/lnt/server/ui/templates/reporting/runs.html
    lnt/trunk/lnt/server/ui/util.py

Modified: lnt/trunk/lnt/server/ui/filters.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/filters.py?rev=264525&r1=264524&r2=264525&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/filters.py (original)
+++ lnt/trunk/lnt/server/ui/filters.py Sat Mar 26 18:01:28 2016
@@ -36,6 +36,11 @@ def filter_urlencode(args):
 def filter_timedelta(start_time):
     return "%.2fs" % (time.time() - start_time)
 
+def filter_producerAsHTML(producer):
+    if not producer:
+        return ""
+    return util.renderProducerAsHTML(producer)
+
 def register(env):
     for name,object in globals().items():
         if name.startswith('filter_'):

Modified: lnt/trunk/lnt/server/ui/templates/reporting/runs.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/runs.html?rev=264525&r1=264524&r2=264525&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/reporting/runs.html (original)
+++ lnt/trunk/lnt/server/ui/templates/reporting/runs.html Sat Mar 26 18:01:28 2016
@@ -87,6 +87,10 @@
       <th style="{{ styles['th'] }}">Order</th>
       <th style="{{ styles['th'] }}">Start Time</th>
       <th style="{{ styles['th'] }}">Duration</th>
+      {%- set show_producers = (run and run.parameters.producer) or(compare_to and compare_to.parameters.producer) or (baseline and baseline.parameters.producer) %}
+      {% if show_producers %}
+        <th style="{{ styles['th'] }}">Produced by</th>
+      {% endif %}
     </tr>
   </thead>
   <tbody>
@@ -97,9 +101,12 @@
       <td style="{{ styles['td'] }}"><a href="{{ ts_url }}/order/{{ r.order.id }}">{{ r.order.llvm_project_revision }}</a></td>
       <td style="{{ styles['td'] }}"><span class="utctime">{{ r.start_time.isoformat() }}</span></td>
       <td style="{{ styles['td'] }}">{{ r.end_time - r.start_time }}</td>
+      {% if show_producers %}
+        <td style="{{ styles['td'] }}">{{ r.parameters.producer|producerAsHTML }}</td>
+      {% endif %}
     </tr>
     {% else %}
-      <tr><td style="{{ styles['td'] }}" colspan=4>No {{ title }} Run</td></tr>
+      <tr><td style="{{ styles['td'] }}" colspan="5">No {{ title }} Run</td></tr>
     {% endif %}
   {% endfor %}
  </tbody>

Modified: lnt/trunk/lnt/server/ui/util.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/util.py?rev=264525&r1=264524&r2=264525&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/util.py (original)
+++ lnt/trunk/lnt/server/ui/util.py Sat Mar 26 18:01:28 2016
@@ -1,5 +1,6 @@
 import colorsys
 import math
+import re
 
 def toColorString(col):
     r,g,b = [clamp(int(v*255), 0, 255)
@@ -269,6 +270,24 @@ def sorted(l, *args, **kwargs):
     l.sort(*args, **kwargs)
     return l
 
+def renderProducerAsHTML(producer):
+    # If the string looks like a buildbot link, render it prettily.
+    m = re.match(r'http://(.*)/builders/(.*)/builds/(\d+)', producer)
+    if m:
+        url = m.group(1)
+        builder = m.group(2)
+        build = m.group(3)
+
+        png_url = 'http://%(url)s/png?builder=%(builder)s&number=%(build)s' % locals()
+        img = '<img src="%(png_url)s">' % locals()
+        return '<a href="%(producer)s">%(builder)s #%(build)s %(img)s</a>' % locals()
+    
+    elif producer.startswith('http://'):
+        return '<a href="' + producer + '">Producer</a>'
+    
+    else:
+        return producer
+
 FLASH_DANGER = "alert alert-danger"
 FLASH_INFO = "alert alert-info"
 FLASH_SUCCESS = "alert alert-success"




More information about the llvm-commits mailing list