diff contrib/sawmill/web/index.py @ 452:333232953771

Initial check-in of sawmill a simple mod_python based web application to render build reports of treepkg.
author Sascha Teichmann <teichmann@intevation.de>
date Fri, 20 Aug 2010 16:15:29 +0000
parents
children d8012571f9e1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/sawmill/web/index.py	Fri Aug 20 16:15:29 2010 +0000
@@ -0,0 +1,40 @@
+# -*- coding: UTF-8 -*-
+#
+# Copyright (C) 2010 by Intevation GmbH
+# Authors:
+# Sascha L. Teichmann <sascha.teichmann@intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+from mod_python import psp
+
+import os
+
+from lxml import etree
+
+TREEPKG_DIR = os.path.join(os.path.dirname(__file__), "treepkgs")
+
+def index(req):
+    req.content_type = 'text/html;charset=utf-8'    
+    template = psp.PSP(req, filename='templates/overview.html')
+
+    descriptions = []
+
+    for f in os.listdir(TREEPKG_DIR):
+        d = os.path.join(TREEPKG_DIR, f)
+        if not os.path.isdir(d): continue
+        treepkg_xml = os.path.join(d, "treepkg.xml")
+        if not os.path.isfile(treepkg_xml): continue
+        xml = None
+        try:
+            xml = open(treepkg_xml, "rb")
+            dom = etree.parse(xml)
+        finally:
+            if xml: xml.close()
+
+        description = ''.join(dom.xpath("//description/text()"))
+
+        descriptions.append((os.path.basename(d), description))
+
+    template.run({'descriptions': descriptions})
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)