[Xfce4-commits] <xfce-buildbot-scripts:master> xfcebuildstatus.py: fix the failed display

Samuel Verstraete noreply at xfce.org
Thu Oct 8 15:34:01 CEST 2009


Updating branch refs/heads/master
         to 9f1808de55d729563b936b019f0e30211b38aa74 (commit)
       from eef2bee45bb094e75bb7d6533479e608e628c5eb (commit)

commit 9f1808de55d729563b936b019f0e30211b38aa74
Author: Samuel Verstraete <samuel.verstraete at gmail.com>
Date:   Thu Oct 8 15:33:35 2009 +0200

    xfcebuildstatus.py: fix the failed display

 xfcebuildstatus.py |   59 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/xfcebuildstatus.py b/xfcebuildstatus.py
old mode 100755
new mode 100644
index d1ef08d..29464ce
--- a/xfcebuildstatus.py
+++ b/xfcebuildstatus.py
@@ -25,11 +25,11 @@ from string import Template
 from datetime import datetime
 import cgi
 import os
+import pprint
 
 
 
-#XMLRPC_URL = 'http://buildbot.xfce.org/core/xmlrpc'
-XMLRPC_URL = 'http://localhost:8020/xmlrpc'
+XMLRPC_URL = 'http://buildbot.xfce.org/core/xmlrpc'
 PLATFORM_NAMES = {
     'debian': 'Debian GNU/Linux 5.0.3 (x86_64)',
     'lunar': 'Lunar Linux (x86_64)'
@@ -96,6 +96,7 @@ ${content}
 </html>"""
 
 
+debug_out = ''
 
 #----------------------------------------------------------------------
 def split_builder_name(input):
@@ -132,7 +133,6 @@ def get_build_status(url):
     platforms = {}
     server = ServerProxy(url)
     builders = server.getLastBuildsAllBuilders(1)
-    #builders.sort()
     for name, no, start, end, branch, revision, status, text, reasons in builders:
         repo, module_name, platform = split_builder_name(name)
         start = datetime.fromtimestamp(start).strftime('%c')
@@ -145,6 +145,23 @@ def get_build_status(url):
     return result
 
 #----------------------------------------------------------------------
+def list_to_str(input):
+    """
+    Convert a passed list into a string, the list elements are separated by commas
+
+    @param input (list)
+    @return result (str)
+    """
+    # TODO this can be expressed much nicer and shorter using map+lambda
+    steps = ''
+    for val in input:
+        if isinstance(val, list):
+            steps += '%s, ' % (' '.join(val))
+        else:
+            steps += '%s, ' % val
+    return steps[0:-2]
+
+#----------------------------------------------------------------------
 def get_build_status_html(url, input):
     """
     Create HTML code from the given input.
@@ -157,13 +174,13 @@ def get_build_status_html(url, input):
     for name in PLATFORM_NAMES.values():
         result += '<td>%s</td>\n' % name
     result += '</tr>\n'
+
     sorted_builders = []
     for x in input.items():
         sorted_builders.append(x)
     sorted_builders.sort(cmp=lambda x,y: cmp(x[0], y[0]))
 
     for module_name, status in sorted_builders:
-    #for module_name, status in input.items():
         result += '<tr>\n<td class="modules">%s</td>\n' % module_name
         for name in PLATFORM_NAMES:
             try:
@@ -172,13 +189,14 @@ def get_build_status_html(url, input):
                                 title="Built revision %s on %s">%s</a></td>\n''' % \
                         (url, status[name][6], status[name][3], status[name][2], status[name][1], status[name][0])
                 elif status[name][0] == 'failure':
-                    status_class = ''
-                    result += type(status[name][4])
-                    result += type(status[name][5])
+                    steps = list_to_str(status[name][4])
+                    reasons = list_to_str(status[name][5])
+                    #~steps = status[name][4]
+                    #~reasons = ''
                     desc = '%s failed to build at %s (on %s, reason: %s)' % \
-                        (module_name, ' '.join(status[name][4]), status[name][1], ' '.join(status[name][5]))
+                        (module_name, steps, status[name][1], reasons)
                     if status[name][2]:
-                        desc += 'Revision %s failed to build on %s' % (status[name][2], status[name][1])
+                        desc += ' Revision %s' % (status[name][2])
                     result += '<td class="status_failed"><a href="%s/detail/f/%s/%d" title="%s">%s</a></td>\n' % \
                         (url, status[name][6], status[name][3], desc, status[name][0])
                 else:
@@ -200,6 +218,7 @@ def get_detail_status(url, args):
     @param args (list)
     @return status per module (dict)
     """
+    global debug_out
     server = ServerProxy(url)
 
     try:
@@ -210,6 +229,7 @@ def get_detail_status(url, args):
     except Exception, e:
         return { }
 
+    debug_out += pprint.pformat(builder)
     return builder
 
 #----------------------------------------------------------------------
@@ -313,17 +333,23 @@ def parse_url():
         if me[0] != '/':
             me = '/%s' % me
         arg_pos = os.environ['REQUEST_URI'].find(me)
-        args = os.environ['REQUEST_URI'][(arg_pos+len(me)+1):].split('/')
+        if arg_pos >= 0:
+            args = os.environ['REQUEST_URI'][(arg_pos+len(me)+1):].split('/')
+        else:
+            me = '/'
+            args = url
         return (me, args)
     except:
         return ('', '')
 
 #----------------------------------------------------------------------
 def main():
-    #~if os.environ['REMOTE_ADDR'] == '127.0.0.1':
+    debug = False
+    if os.environ['REMOTE_ADDR'] in ['127.0.0.1', '62.75.200.254']:
         # debug :)
-    import cgitb
-    cgitb.enable(display=1)
+        import cgitb
+        cgitb.enable(display=1)
+        debug = True
 
     # handle arguments
     url, args = parse_url()
@@ -354,12 +380,9 @@ def main():
     print # final blank line to end HTTP headers
 
     print output
+    if debug and debug_out:
+        print debug_out
 
 main()
 
 
-# TODO
-# - sort
-# - detail
-
-



More information about the Xfce4-commits mailing list