[Piuparts-devel] Bug#705975: piuparts-report rpy charting broken
Dave Steele
dsteele at gmail.com
Tue Apr 23 01:12:21 UTC 2013
Package: piuparts
Version: 0.50
Severity: normal
Tags: patch
thanks
Recent upgrades to r-base-core and python-rpy have broken chart
creation in piuparts-report in sid. The changes to 'R' have introduced
a failure in the 'palette' call:
20:31:54 analysis template obsolete_conffiles_error.tpl does not exist.
No protocol specified
Warning message:
In (function (display = "", width, height, pointsize, gamma, bg, :
unable to open connection to X11 display ''
20:31:54 Error generating the graph images, probably python-rpy is not
installed, disabling graphs.
20:31:54 Writing stats pages for squeeze
This is fixed in the patch below by providing a virtual X11
framebuffer for 'R' to use.
The python-rpy upgrade broke the module - it fails to import. The
patch ports the charting from the obsolete python-rpy to the supported
python-rpy2. The python-rpy problem is fixed in #705847, associated
with rpy 1.0.3-25.
The git branch 'port-to-rpy2'(3) is available:
https://github.com/davesteele/piuparts/commit/port-to-rpy2
This is a kluge fix, useful for quickly restoring charts to a sid
instance, but not recommended for production (piuparts-report reports
a segfault at the end of its run). It is recommended that rpy* be
replaced with a more mainline charting package, like matplotlib, for a
more permanent fix.
I have posted this to piuparts, not piuparts-master, assuming that is
the preferred location.
>From e65e182ca6cac928573938839a0559732d9f31de Mon Sep 17 00:00:00 2001
From: David Steele <dsteele at gmail.com>
Date: Sat, 20 Apr 2013 20:24:19 -0400
Subject: [PATCH] piuparts-report - Fix breakage in 'R' charting.
Recent changes in sid for 'R' and python-rpy have broken chart creation.
There are two problems, 1) python-rpy, a legacy package, will not import
after the upgrade, and 2) some of the 'r' commands are expecting to be
interacting with an X frame buffer.
This commit restores charts by 1) porting the chart creation code to
python-rpy2, and 2) providing a virtual frame buffer.
---
debian/changelog | 2 ++
debian/control | 3 ++-
piuparts-report.py | 45 +++++++++++++++++++++++++++------------------
3 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index b4d1c4d..6236100 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -58,6 +58,8 @@ piuparts (0.51) UNRELEASED; urgency=low
* New known problem: Database setup failure (issue).
[ David Steele ]
+ * piuparts-report:
+ - Upgrade package stat charting from python-rpy to python-rpy2
* detect_well_known_errors:
- Replace the bash script with an equivalent Python script.
- Sort known error and issue packages by reverse dependency count,
diff --git a/debian/control b/debian/control
index 8f895c2..c2dd58f 100644
--- a/debian/control
+++ b/debian/control
@@ -51,12 +51,13 @@ Depends:
openssh-server,
python-debianbts,
tango-icon-theme,
+ xvfb,
${misc:Depends},
${python:Depends}
Recommends:
apache2,
ghostscript,
- python-rpy,
+ python-rpy2,
r-base-dev,
r-recommended,
Breaks:
diff --git a/piuparts-report.py b/piuparts-report.py
index 996ca2a..b92f1f8 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -35,10 +35,11 @@ import urllib
import shutil
import re
import string
+import subprocess
-# if python-rpy ain't installed, we don't draw fancy graphs
+# if python-rpy2 ain't installed, we don't draw fancy graphs
try:
- from rpy import *
+ import rpy2.robjects as robjects
except:
pass
@@ -1063,22 +1064,30 @@ class Section:
def make_stats_graph(self):
countsfile = os.path.join(self._output_directory, "counts.txt")
pngfile = os.path.join(self._output_directory, "states.png")
- r('t <- (read.table("'+countsfile+'",sep=",",header=1,row.names=1))')
- r('cname <- c("date",rep(colnames(t)))')
- # here we define how many days we wants stats for (163=half a year)
- #r('v <- t[(nrow(t)-163):nrow(t),0:12]')
- # make graph since day 1
- r('v <- t[0:nrow(t),0:12]')
- # thanks to http://tango.freedesktop.org/Generic_Icon_Theme_Guidelines
- r('palette(c("#4e9a06", "#ef2929", "#d3d7cf", "#5c3566", "#c4a000", \
- "#fce94f", "#a40000", "#888a85", "#2e3436", "#729fcf", \
- "#3465a4", "#204a87", "#555753"))')
- r('bitmap(file="'+pngfile+'",type="png16m",width=16,height=9,pointsize=
- r('barplot(t(v),col = 1:13, \
- main="Binary packages per state in '+self._config.section+'", \
- xlab="", ylab="Number of binary packages", space=0.1, border=0)')
- r('legend(x="bottom",legend=colnames(t), ncol=2,fill=1:13,xjust=0.5,yju
- r.dev_off()
+
+ xvfb = subprocess.Popen(['Xvfb', ':99'], stdout=open(os.devnull, 'wb'),
+ stderr=open(os.devnull, 'wb'))
+ os.environ["DISPLAY"] = ":99"
+
+ try:
+ robjects.r('t <- (read.table("'+countsfile+'",sep=",",header=1,row.
+ robjects.r('cname <- c("date",rep(colnames(t)))')
+ # here we define how many days we wants stats for (163=half a year)
+ #robjects.r('v <- t[(nrow(t)-163):nrow(t),0:12]')
+ # make graph since day 1
+ robjects.r('v <- t[0:nrow(t),0:12]')
+ # thanks to http://tango.freedesktop.org/Generic_Icon_Theme_Guideli
+ # for those nice colors
+ robjects.r('palette(c("#4e9a06", "#ef2929", "#d3d7cf", "#5c3566",\
+ "#c4a000", "#fce94f", "#a40000", "#888a85", "#2e3436",\
+ "#729fcf", "#3465a4", "#204a87", "#555753"))')
+ robjects.r('bitmap(file="'+pngfile+'",type="png16m",width=16,height
+ robjects.r('barplot(t(v),col = 1:13, \
+ main="Binary packages per state in '+self._config.section+'", \
+ xlab="", ylab="Number of binary packages", space=0.1, border=0)')
+ robjects.r('legend(x="bottom",legend=colnames(t), ncol=2,fill=1:13,
+ finally:
+ xvfb.terminate()
stats_html = "<tr class=\"normalrow\"> " \
+ "<td class=\"contentcell2\" colspan=\"3\">" \
--
1.7.10.4
(END)
More information about the Piuparts-devel
mailing list