[Xfce4-commits] <xfce-buildbot-scripts:master> Lots of fixes

Enrico Tröger noreply at xfce.org
Thu Oct 8 20:38:01 CEST 2009


Updating branch refs/heads/master
         to a23946488d779aa3fabbf01bb3e8580e61c4d374 (commit)
       from d625d189305268b14396d3e7940e51b3913bd984 (commit)

commit a23946488d779aa3fabbf01bb3e8580e61c4d374
Author: Enrico Tröger <enrico.troeger at uvena.de>
Date:   Thu Oct 8 20:35:40 2009 +0200

    Lots of fixes
    
    - Remove the source link as the script is now maintained in the GIT repository
    - On the overview page, display only the short GIT revision
    - Fix URI and arguments parsing
    - Improve debug mode, to be enabled by appending ?debug

 xfcebuildstatus.py |   48 +++++++++++++++++++-----------------------------
 1 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/xfcebuildstatus.py b/xfcebuildstatus.py
index 29464ce..51dc1fd 100644
--- a/xfcebuildstatus.py
+++ b/xfcebuildstatus.py
@@ -76,10 +76,6 @@ template = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         .status_unknown {
             background-color: #ffff00;
         }
-        .source {
-            padding-top: 15px;
-            font-size: 11px;
-        }
         .item {
             font-weight: bold;
         }
@@ -180,6 +176,7 @@ def get_build_status_html(url, input):
         sorted_builders.append(x)
     sorted_builders.sort(cmp=lambda x,y: cmp(x[0], y[0]))
 
+    # TODO rewrite this code to be clean
     for module_name, status in sorted_builders:
         result += '<tr>\n<td class="modules">%s</td>\n' % module_name
         for name in PLATFORM_NAMES:
@@ -187,16 +184,14 @@ def get_build_status_html(url, input):
                 if status[name][0] == 'success':
                     result += '''<td class="status_success"><a href="%s/detail/s/%s/%d"
                                 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])
+                        (url, status[name][6], status[name][3], status[name][2][:7], status[name][1], status[name][0])
                 elif status[name][0] == 'failure':
                     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, steps, status[name][1], reasons)
                     if status[name][2]:
-                        desc += ' Revision %s' % (status[name][2])
+                        desc += ' Revision %s' % (status[name][2][:7])
                     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:
@@ -205,8 +200,6 @@ def get_build_status_html(url, input):
                 result += '<td class="status_unknown">unknown</td>\n'
         result += '</tr>\n'
 
-    result += '</table>\n<p class="source"><a href="%s/source">Script Source</a></p>' % url
-
     return Template(template).substitute(content=result)
 
 #----------------------------------------------------------------------
@@ -316,7 +309,8 @@ def get_detail_status_html(url, input):
         result += '<p><span class="item">More details:</span> <a href="%s">%s</a></p>\n' % (input['url'], input['url'])
 
     else:
-        # do something here
+        # TODO do something here
+        result = 'Currently no information for failed builds can be retrieved :('
         pass
 
     return Template(template).substitute(content=result)
@@ -329,41 +323,37 @@ def parse_url():
     @return url, args (tuple)
     """
     try:
+        uri = os.environ['REQUEST_URI']
         me = os.path.basename(os.environ['SCRIPT_FILENAME'])
         if me[0] != '/':
             me = '/%s' % me
-        arg_pos = os.environ['REQUEST_URI'].find(me)
+        arg_pos = uri.find(me)
         if arg_pos >= 0:
-            args = os.environ['REQUEST_URI'][(arg_pos+len(me)+1):].split('/')
+            args = uri[(arg_pos+len(me)+1):].split('/')
         else:
-            me = '/'
-            args = url
+            me = ''
+            args = uri.split('/')
+            if not args[0]:
+				del args[0]
         return (me, args)
     except:
         return ('', '')
 
 #----------------------------------------------------------------------
 def main():
-    debug = False
-    if os.environ['REMOTE_ADDR'] in ['127.0.0.1', '62.75.200.254']:
-        # debug :)
+    debug = cgi.FieldStorage(keep_blank_values=True).has_key('debug')
+    if debug:
         import cgitb
         cgitb.enable(display=1)
-        debug = True
 
     # handle arguments
     url, args = parse_url()
 
     output = ''
     headers = []
-    if args and args[0]:
-        if args[0] == 'source':
-            headers.append('Content-Disposition: attachment; filename=%s' % url)
-            headers.append('Content-type: text/x-python')
-            fp = open(__file__, 'r')
-            output = fp.read()
-            fp.close()
-        elif args[0] == 'detail' and len(args) == 4:
+    if args:
+        args_len = len(args)
+        if args[0] == 'detail' and args_len == 4:
             status = get_detail_status(XMLRPC_URL, args)
             output = get_detail_status_html(url, status)
 
@@ -380,9 +370,9 @@ def main():
     print # final blank line to end HTTP headers
 
     print output
-    if debug and debug_out:
+    if debug:
         print debug_out
+        print os.environ
 
 main()
 
-



More information about the Xfce4-commits mailing list