06256: Can't create graph reports

svn: r21001
This commit is contained in:
Benny Malengier 2013-01-05 13:33:03 +00:00
parent 17824534cb
commit ddd1aae5c3

View File

@ -633,7 +633,10 @@ class GVPsDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
@ -650,10 +653,13 @@ class GVPsDoc(GVDocBase):
# See bug tracker issue 2815
# :cairo does not work with Graphviz 2.26.3 and later See issue 4164
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
command = 'dot -Tps:cairo -o"%s" "%s"' % (fname, tmp_dot)
dotversion = Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1]
dotversion = str(Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1])
# Problem with dot 2.26.3 and later and multiple pages, which gives "cairo: out of
# memory" If the :cairo is skipped for these cases it gives acceptable
# result.
@ -688,11 +694,17 @@ class GVSvgDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
# Generate the SVG file.
os.system( 'dot -Tsvg -o"%s" "%s"' % (fname, tmp_dot) )
@ -725,11 +737,17 @@ class GVSvgzDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
# Generate the SVGZ file.
os.system( 'dot -Tsvgz -o"%s" "%s"' % (fname, tmp_dot) )
@ -762,11 +780,17 @@ class GVPngDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
# Generate the PNG file.
os.system( 'dot -Tpng -o"%s" "%s"' % (fname, tmp_dot) )
@ -799,11 +823,17 @@ class GVJpegDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
# Generate the JPEG file.
os.system( 'dot -Tjpg -o"%s" "%s"' % (fname, tmp_dot) )
@ -836,11 +866,17 @@ class GVGifDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
# Generate the GIF file.
os.system( 'dot -Tgif -o"%s" "%s"' % (fname, tmp_dot) )
@ -882,8 +918,11 @@ class GVPdfGvDoc(GVDocBase):
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
# Covert filename to str using file system encoding.
fname = self._filename.encode(sys.getfilesystemencoding())
# Convert filename to str using file system encoding.
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
# Generate the PDF file.
os.system( 'dot -Tpdf -o"%s" "%s"' % (fname, tmp_dot) )
@ -914,7 +953,10 @@ class GVPdfGsDoc(GVDocBase):
# Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".gv" )
dotfile = os.fdopen(handle,"w")
if sys.version_info[0] < 3:
dotfile = os.fdopen(handle, "w")
else:
dotfile = os.fdopen(handle, "wb")
dotfile.write(self._dot.getvalue())
dotfile.close()
@ -928,7 +970,7 @@ class GVPdfGsDoc(GVDocBase):
# :cairo does not work with Graphviz 2.26.3 and later See issue 4164
command = 'dot -Tps:cairo -o"%s" "%s"' % ( tmp_ps, tmp_dot )
dotversion = Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1]
dotversion = str(Popen(['dot', '-V'], stderr=PIPE).communicate(input=None)[1])
# Problem with dot 2.26.3 and later and multiple pages, which gives "cairo: out
# of memory". If the :cairo is skipped for these cases it gives
# acceptable result.
@ -942,7 +984,10 @@ class GVPdfGsDoc(GVDocBase):
height_pt = int( (paper_size.get_height_inches() * 72) + 0.5 )
# Convert to PDF using ghostscript
fname = self._filename.encode(sys.getfilesystemencoding())
if sys.version_info[0] < 3:
fname = self._filename.encode(sys.getfilesystemencoding())
else:
fname = self._filename
command = '%s -q -sDEVICE=pdfwrite -dNOPAUSE -dDEVICEWIDTHPOINTS=%d' \
' -dDEVICEHEIGHTPOINTS=%d -sOutputFile="%s" "%s" -c quit' \
% ( _GS_CMD, width_pt, height_pt, fname, tmp_ps )