[Piuparts-commits] rev 381 - in trunk: . debian

Holger Levsen holger at alioth.debian.org
Wed Apr 29 09:10:58 UTC 2009


Author: holger
Date: 2009-04-29 09:10:58 +0000 (Wed, 29 Apr 2009)
New Revision: 381

Modified:
   trunk/debian/changelog
   trunk/piuparts-report.py
Log:
handly gracefully if python-rpy aint installed

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2009-04-29 08:36:53 UTC (rev 380)
+++ trunk/debian/changelog	2009-04-29 09:10:58 UTC (rev 381)
@@ -49,7 +49,7 @@
     - provide links to logfiles in statistics page.
     - provide links to source packages pages from state pages and back, as well
       as links to the dependencies state.
-    - draw graphs of package states over time.
+    - draw graphs of package states over time (if pypthon-rpy is installed).
     - improve layout, generate navigation for all pages.
   * Break backwards compatibility of the configuration files for master-slave-
     mode. Merge those three into one: /etc/piuparts/piuparts/piuparts.conf.
@@ -65,7 +65,7 @@
     - depend on python (>>2.4), make dependency to python-debian unversioned
     - add build-dependencies on debhelper, asciidoc and xmlto.
     - remove build-dependencies on docbook2x and docbook-xml.
-    - suggest python-rpy which is needed for piuparts-reports.
+    - suggest python-rpy as it improves piuparts-reports output.
     - set Homepage: to http://piuparts.debian.org
     - bump Standards-Version to 3.8.1, no changes neccessary.
   * Rewrite debian/rules from scratch using debhelper.

Modified: trunk/piuparts-report.py
===================================================================
--- trunk/piuparts-report.py	2009-04-29 08:36:53 UTC (rev 380)
+++ trunk/piuparts-report.py	2009-04-29 09:10:58 UTC (rev 381)
@@ -31,8 +31,13 @@
 import urllib
 import shutil
 import string
-from rpy import *
 
+# if python-rpy ain't installed, we don't draw fancy graphs
+try:
+  from rpy import *
+except:
+  pass
+
 import piupartslib
 
 
@@ -744,16 +749,20 @@
 
         # create and include graph
         # FIXME: refactor!  
-        countsfile = os.path.join(self._output_directory, "counts.txt")
-        pngfile = os.path.join(self._output_directory, "monthly-states.png")
-        r('t <- (read.table("'+countsfile+'",sep=",",header=1,row.names=1))')
-        r('cname <- c("date",rep(colnames(t)))')
-        r('v <- t[(nrow(t)-28):nrow(t),0:12]')
-        r('palette(c("green4", "red", "green", "brown", "black", "skyblue4", "yellow", "darkred", "salmon", "purple", "lightgreen",  "blue","darkgray"))')
-        r('bitmap(file="'+pngfile+'",type="png16m",width=12,height=9,pointsize=10,res=100)')
-        r('barplot(t(v),col = 1:13, main="Packages per state in '+self._config.section+' (past 4 weeks)", xlab="", ylab="Number of packages",space=0.1,border=0)')
-        r('legend(x="bottom",legend=colnames(t), ncol=2,fill=1:13,xjust=0.5,yjust=0,bty="n")')
-        tablerows += "<tr class=\"normalrow\"> <td class=\"contentcell\" colspan=\"3\"><a href=\"%s\"><img src=\"/%s/%s\" height=\"450\" width=\"600\" alt=\"Package states in the 4 weeks\"></a></td></tr>\n" % ("monthly-states.png", self._config.section, "monthly-states.png")
+        # if python-rpy ain't installed, we don't draw fancy graphs
+        try:
+          countsfile = os.path.join(self._output_directory, "counts.txt")
+          pngfile = os.path.join(self._output_directory, "monthly-states.png")
+          r('t <- (read.table("'+countsfile+'",sep=",",header=1,row.names=1))')
+          r('cname <- c("date",rep(colnames(t)))')
+          r('v <- t[(nrow(t)-28):nrow(t),0:12]')
+          r('palette(c("green4", "red", "green", "brown", "black", "skyblue4", "yellow", "darkred", "salmon", "purple", "lightgreen",  "blue","darkgray"))')
+          r('bitmap(file="'+pngfile+'",type="png16m",width=12,height=9,pointsize=10,res=100)')
+          r('barplot(t(v),col = 1:13, main="Packages per state in '+self._config.section+' (past 4 weeks)", xlab="", ylab="Number of packages",space=0.1,border=0)')
+          r('legend(x="bottom",legend=colnames(t), ncol=2,fill=1:13,xjust=0.5,yjust=0,bty="n")')
+          tablerows += "<tr class=\"normalrow\"> <td class=\"contentcell\" colspan=\"3\"><a href=\"%s\"><img src=\"/%s/%s\" height=\"450\" width=\"600\" alt=\"Package states in the 4 weeks\"></a></td></tr>\n" % ("monthly-states.png", self._config.section, "monthly-states.png")
+        except:
+          logging.debug("python-rpy not installed, disabled graphs.")
 
         tablerows += "<tr class=\"normalrow\"> <td class=\"labelcell\">Total</td> <td class=\"labelcell\" colspan=\"2\">%d</td></tr>\n" % \
                           self._binary_db.get_total_packages()




More information about the Piuparts-commits mailing list