[IPython-user] os.startfile -> infinite loop

Ryan Krauss ryanfedora at comcast.net
Mon Aug 15 07:16:47 CDT 2005


I know this seems like a YAP problem because I don't have the problem 
with PDF files (and it may well be that it is something I have done to 
YAP), but I don't have the problem if I run the script from python 
directly rather than Ipython (but then it takes forever to re-run the 
script because it is re-importing each time).

Ryan

Ryan Krauss wrote:
> I have an interesting problem with os.startfile and Ipython.  I have a 
> script that generates a LaTeX file and runs LaTeX.  I then open the 
> output with os.startfile.  On my computer at home, I have no problems.  
> On the computer in my office, I have no problems if I run pdflatex and 
> open a pdf file (with Acrobat).  However, if I generate a dvi file and 
> open it with YAP, it starts an infinite loop.  I know this sounds 
> crazy.  I will attach the python script.
> 
> If I comment out this line
> os.startfile(ostr)  (line 77)
> the code exits normally.
> 
> If I leave this line in and I am opening a dvi file, the script goes all 
> the way back to the begining and re-executes continually.
> 
> Any thoughts?
> 
> Ryan
> 
> 
> ------------------------------------------------------------------------
> 
> import time
> ta1=time.time()
> import rwkascii
> reload(rwkascii)
> ta2=time.time()
> print('import ascii time='+str(ta2-ta1))
> import os
> import pdb
> from rwkos import FindFullPath
> 
> ts=time.time()
> maximapath='maxima'
> latexcmd='latex'
> viewerext='.dvi'
> #latexcmd='pdflatex'
> #viewerext='.pdf'
> #pdb.set_trace()
> mydir=FindFullPath('GT\\Research\\Samii\\modeling\\Feedback')
> inname='noncolocated.tex'
> fno,ext=os.path.splitext(inname)
> outname=fno+'_out'+ext
> mylist=rwkascii.rwklatexlist([],outname)
> mylist.readfile(inname)
> 
> #pdb.set_trace()
> b4lines,maximalines, endlines=mylist.findenvironments('maxima',0)
> maxpath=os.path.join(mydir,fno+'.max')
> eqdir=os.path.join(mydir,'noncolocated_eqs')
> if not os.path.exists(eqdir):
>     os.mkdir(eqdir)
> #pdb.set_trace()
> outlines=rwkascii.BuildMaximaScript(maximalines, maxpath, eqdir, 'maxeq')
> 
> maxpath_fs=maxpath.replace('\\','/')
> maximastr=maximapath+' -b '+maxpath_fs
> #os.system(maximastr)
> r,w=os.popen2(maximastr)
> #maxe=e.readlines()
> #e.close()
> maxo=w.readlines()
> w.close()
> #r.close()
> if rwkascii.searchlist(maxo,'Incorrect syntax'):
>     for line in maxo:
>         print(line.strip())
> #pdb.set_trace()
> findlist=['Fa','xa']
> replist=['F_a','x_a']
> #pdb.set_trace()
> tr1=time.time()
> outbiglist=rwkascii.ReadMaximaOutput(outlines,findlist,replist)
> tr2=time.time()
> print('ReadMaxima time='+str(tr2-tr1))
> newlist=rwkascii.rwklatexlist([],outname)
> newlist.list=mylist.reassemble(b4lines,outbiglist,endlines)
> #newlist.wrapeq()
> newlist.addheader()
> newlist.tofile()
> 
> #latexstr1=latexcmd+' -interaction=batchmode '+outname
> latexstr2=latexcmd+' -interaction=nonstopmode '+outname
> r,w=os.popen2(latexstr2)
> texout=w.readlines()
> w.close()
> r.close()
> if rwkascii.searchlist(texout,'LaTeX Error'):
>     for line in texout:
>         print(line.strip())
> if rwkascii.searchlist(texout,'Label(s) may have changed'):
>     print('Running LaTeX a second time.')
>     r,w=os.popen2(latexstr2)
>     texout=w.readlines()
>     w.close()
>     r.close()
> outfno,ext=os.path.splitext(outname)
> ostr=outfno+viewerext
> os.startfile(ostr)
> te=time.time()
> print('run time='+str(te-ts))
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> IPython-user mailing list
> IPython-user at scipy.net
> http://scipy.net/mailman/listinfo/ipython-user




More information about the IPython-user mailing list