From: Ryan K. <rya...@gm...> - 2006-03-08 13:43:04
|
I think I got it. I had to play around a bit with a couple different approaches. Part of the trick is that you have to run latex with -interaction=3Dnonstopmode, otherwise the child process never completes and it seems like most of python's tools for capturing the errors and outputs just hang. Here is what I did: import popen2 In [8]: latexcmd3=3Dpopen2.Popen3('latex -interaction=3Dnonstopmode bad.tex= ') In [9]: latexcmd3.wait() Out[9]: 256 In [10]: latexcmd4=3Dpopen2.Popen3('latex -interaction=3Dnonstopmode good.t= ex') In [11]: latexcmd4.wait() Out[11]: 0 where bad.tex and good.tex basically have just headers and \frac{1}{\theta} with and without $$ around it. If I just use os.popen3, the stderr object returned is empty in both cases: In [14]: r,w,e=3Dos.popen3('latex -interaction=3Dnonstopmode good.tex') In [15]: e.readlines() Out[15]: [] In [16]: r,w,e=3Dos.popen3('latex -interaction=3Dnonstopmode bad.tex') In [17]: e.readlines() Out[17]: [] and to know there was a problem, you would have to parse w.readlines() - and in this case it doesn't even say there is an error, it mentions something about a missing $. But it seems like creating your own Popen3 object and executing it through the wait() command, returns 0 on a clean exit or 256 on the bad ones (at least for this error). I have compiled one other good file from my hard drive and it also returns 0. Hope this helps, Ryan On 3/8/06, Darren Dale <dd...@co...> wrote: > >> On Wednesday 08 March 2006 5:06 am, Nils Wagner wrote: > >> > >>> Hi all, > >>> > >>> How do I use \frac{a}{b} within labels ? > >>> > >>> from pylab import * > >>> from scipy import * > >>> x =3D linspace(0,pi,20) > >>> plot(x,sin(x)) > >>> title(r'\frac{\Theta}{2\pi}') > >>> xlabel(r'\frac{\Theta}{2\pi}') # The output is not o.k. > >>> show() > >>> > >>> Am I missing something or is it a bug ? > >>> > >> > >> What does "The output is not o.k." mean? > >> > > The output is somewhat like \Theta \frac{}{2\pi} > > If I use > > xlabel(r'$\frac{\Theta}{2\pi}$') > > > > it works fine. > > This is not a bug. Please keep in mind that usetex is really only an inte= rface > to latex. For problems specific to LaTeX, it would be best to consult the > appropriate sources or lists. As it happens, \frac is only allowed in mat= h > mode. That it produced any output at outside of mathmode is a case of fai= ling > silently. > > Does anyone know how to catch exit status using os.popen and friends? LaT= eX > would have returned an exit status of 1 for this example, which could be = used > to raise a warning. > > Darren > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmdlnk&kid=110944&bid$1720&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |