I am using graphviz dot to generate some svg graphs for a web application. I call the point using Popen:
p = subprocess.Popen(u'/usr/bin/dot -Kfdp -Tsvg', shell=True,\ stdin=subprocess.PIPE, stdout=subprocess.PIPE) str = u'long-unicode-string-i-want-to-convert' (stdout,stderr) = p.communicate(str)
What happens is that the point program throws errors, for example:
Error: not well-formed (invalid token) in line 1 ... <tr><td cellpadding="4bgcolor="
This obvious error is most likely NOT in the input line. In particular, if I save it in str.txt with utf-8 encoding and do
/usr/bin/dot -Kfdp -Tsvg < str.txt > myimg.svg
I get the desired result. The only “special” thing about str is that it contains characters such as Danish øæå.
Now I have no idea what to do. The problem can be very successful; but, apparently, this is apparently due to the fact that Popen is different from using <from the shell, and I have no idea where to start. Any help or ideas for an alternative point call (besides writing all the data to a file and calling this!) Would be greatly appreciated!
source share