[Blends-commit] [SCM] website branch, master, updated. d0cb9f6ab6340b0feb767e4bbd75a861686da7ec

Andreas Tille tille at debian.org
Fri Jul 5 17:59:26 UTC 2013


The following commit has been merged in the master branch:
commit d0cb9f6ab6340b0feb767e4bbd75a861686da7ec
Author: Andreas Tille <tille at debian.org>
Date:   Fri Jul 5 19:45:18 2013 +0200

    Very basic genshi template to get some html output

diff --git a/misc/thermometer/templates/thermometer.xhtml b/misc/thermometer/templates/thermometer.xhtml
new file mode 100644
index 0000000..757616f
--- /dev/null
+++ b/misc/thermometer/templates/thermometer.xhtml
@@ -0,0 +1,30 @@
+<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
+      xmlns:py="http://genshi.edgewall.org/">
+<head>
+<title>$projectname Thermometer</title>
+<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
+<link href="../inc/style.css" type="text/css" rel="stylesheet"/>
+</head>
+<body>
+<table class="pkg">
+<caption><h3>$projectname Package Thermometer</h3></caption>
+<tr class='title'>
+ <th>Package</th>
+ <th>stable</th><th>testing</th><th>unstable</th><th>stable-bpo</th>
+</tr>
+<py:for each="pkg in blend_data">
+ <tr>
+  <td>${pkg.source}</td>
+  <td>${pkg.stable}</td><td>${pkg.testing}</td><td>${pkg.unstable}</td><td>${pkg.stable_bpo}</td>
+ </tr>
+</py:for>
+</table>
+<div id="footer">
+  <hr class="hidecss" />
+  <address>${updatetimestamp}</address>
+</div>
+</body>
+</html>
diff --git a/misc/thermometer/thermometer.py b/misc/thermometer/thermometer.py
index abfba3d..f99ff96 100755
--- a/misc/thermometer/thermometer.py
+++ b/misc/thermometer/thermometer.py
@@ -8,9 +8,17 @@ PORT=UDDPORT
 DEFAULTPORT=5432
 
 from sys import stderr, exit
+import os
 import psycopg2
 import json
 import re
+import time
+from datetime import datetime
+from email.Utils import formatdate
+
+from genshi.template import TemplateLoader
+from genshi import Markup
+from genshi.template.eval import UndefinedError
 
 ###########################################################################################
 # Define several prepared statements to query UDD
@@ -72,7 +80,7 @@ query = """PREPARE query_thermometer (text) AS
        stable.version AS stable,
        testing.version AS testing,
        unstable.version AS unstable,
-       stable_bpo.version AS "stable-bpo",
+       stable_bpo.version AS "stable_bpo",
        experimental.version AS experimental,
        unreleased.version AS "UNRELEASED",
        precise.version AS precise,
@@ -226,7 +234,42 @@ blendname = 'debian-med'
 _execute_udd_query( "EXECUTE query_thermometer('%s')" % blendname)
 
 if curs.rowcount > 0:
+    blend_data = RowDictionaries(curs)
     f = open('thermometer.json', 'w')
-    print >>f, json.dumps(RowDictionaries(curs))
+    print >>f, json.dumps(blend_data)
     f.close()
+else:
+    print >>stderr, "No data received for Blend", blendname
+    exit(1)
+
+# Define directories used
+current_dir  = os.path.dirname(__file__)
+# locale_dir   = os.path.join(current_dir, 'locale')
+template_dir = os.path.join(current_dir, 'templates')
+
+# initialize gensi
+loader = TemplateLoader([template_dir], auto_reload=True)
+
+#outputdir = tasks.CheckOrCreateOutputDir('thermometer')
+outputdir = './thermometer'
+if outputdir == None:
+        exit(-1)
+
+t = datetime.now()
+
+template = loader.load('thermometer.xhtml')
+outputfile = outputdir + '/thermometer.html'
+try:
+    os.unlink(outputfile)
+except: # simply continue if file does not exist
+    pass
+
+data={}
+data['projectname'] = blendname
+data['blend_data']  = blend_data
+# data['updatetimestamp']   = to_unicode(_('Last update:')) + ' ' + formatdate(time.mktime(t.timetuple()))
+data['updatetimestamp']   = 'Last update:' + ' ' + formatdate(time.mktime(t.timetuple()))
 
+f = open(outputfile, 'w')
+print >> f, template.generate(**data).render('xhtml')
+f.close()

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list