diff contrib/sawmill/web/details.py @ 490:73a2e603a23b

sawmill: Prepared detail view for syndication: Added anchors for each build and added render rel link if RSS file exists next to treepkg.xml.
author Sascha Teichmann <teichmann@intevation.de>
date Wed, 29 Sep 2010 19:25:52 +0000
parents f208b139190b
children
line wrap: on
line diff
--- a/contrib/sawmill/web/details.py	Sun Sep 26 08:53:16 2010 +0000
+++ b/contrib/sawmill/web/details.py	Wed Sep 29 19:25:52 2010 +0000
@@ -24,6 +24,8 @@
 
 UNDER_SCORE = re.compile(r"_+(\w)")
 
+INVALID_LABEL = re.compile(r"[^a-zA-Z0-9_]")
+
 def _create_time(s, format="%Y-%m-%d %H:%M:%S"):
     return datetime.datetime(*(time.strptime(s, format)[0:6]))
 
@@ -31,6 +33,9 @@
     log = log.replace(".txt", "").replace(".gz", "").capitalize()
     return UNDER_SCORE.sub(lambda x: " %s" % x.group(1).upper(), log)
 
+def _make_valid_label(label):
+    return INVALID_LABEL.sub("_", label)
+
 class TrackItem(object):
 
     def __init__(self, treepkg, track, revision, status_file):
@@ -78,6 +83,15 @@
         self.check_loaded()
         return self.tags
 
+    def get_label(self):
+        self.check_loaded()
+        out = [
+            _make_valid_label(self.track),
+            _make_valid_label(self.revision) ]
+        if self.start:
+            out.append(self.start.strftime("%Y%m%d%H%M%S"))
+        return ''.join(out)
+
     def log_path(self, log):
         return "%s/tracks/%s/pkg/%s/log/%s" % (
             self.treepkg, self.track, self.revision, log)
@@ -99,6 +113,7 @@
     build_stop   = property(get_build_stop)
     build_logs   = property(get_build_logs)
     build_tags   = property(get_tags)
+    build_label  = property(get_label)
 
 
 def __scan_track_items(treepkg, path):
@@ -139,28 +154,35 @@
 def index(req, treepkg=''):
     if not treepkg: util.redirect(req, "index.py")
 
-    found = None
+    package_dir = None
     for d in os.listdir(TREEPKG_DIR):
         dp = os.path.join(TREEPKG_DIR, d)
         if d == treepkg and os.path.isdir(dp):
-            found = dp
+            package_dir = dp
             break
 
-    if not found:
+    if not package_dir:
         req.status = apache.HTTP_NOT_FOUND
         return "requested TreePkg not found"
 
-    description, header = __description_header(found)
+    description, header = __description_header(package_dir)
 
-    track_items = __scan_track_items(treepkg, found)
+    track_items = __scan_track_items(treepkg, package_dir)
 
-    req.content_type = 'text/html;charset=utf-8'
-    template = psp.PSP(req, filename='templates/details.html')
-    template.run({
+    parameters = {
         'page_title' : description,
         'back_link'  : 'index.py',
         'base_dir'   : BASE_DIR,
         'description': description,
         'header'     : header,
         'track_items': track_items
-    })
+    }
+
+    if os.path.isfile(os.path.join(package_dir, "rss.xml")):
+        parameters['syndicate'] = (
+            'Build error feed',
+            'treepkgs/%s/rss.xml' % treepkg)
+
+    req.content_type = 'text/html;charset=utf-8'
+    template = psp.PSP(req, filename='templates/details.html')
+    template.run(parameters)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)