G
Guest
Hello all
I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho:
Import os, subprocess
def main():
scriptpath = os.path.dirname(__file__)
p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex"
% (scriptpath, scriptpath, scriptpath),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=scriptpath)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
print 'stdin'
print child_stdin
print 'stdout'
print child_stdout
print 'stderr'
print child_stderr
When I run that code I get the following printouts:
stdin
<open file '<fdopen>', mode 'wb' at 0x009E7968>
stdout
<open file '<fdopen>', mode 'rb' at 0x009E7A40>
stderr
<open file '<fdopen>', mode 'rb' at 0x009E79F8>
Done
The pdf file however is not created, nor are there any tex-temporary files (like *.log or *.aux) created. If I include a 'p.wait()' I see the python.exe and the pdflatex.exe processes are running, but I have it to terminate them manually (they never finish). My system is winXP btw.
Does anyone have an idea what could be wrong? The reason why I want to use the Popen class is because it has the wait() function, so I can wait for the childprocess (pdflatex) to terminate before I start it again (because you need to run pdflatex several times to get all the references/index things correct in the generated pdf).
Thanks for help,
Dominique
I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho:
Import os, subprocess
def main():
scriptpath = os.path.dirname(__file__)
p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex"
% (scriptpath, scriptpath, scriptpath),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=scriptpath)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
print 'stdin'
print child_stdin
print 'stdout'
print child_stdout
print 'stderr'
print child_stderr
When I run that code I get the following printouts:
stdin
<open file '<fdopen>', mode 'wb' at 0x009E7968>
stdout
<open file '<fdopen>', mode 'rb' at 0x009E7A40>
stderr
<open file '<fdopen>', mode 'rb' at 0x009E79F8>
Done
The pdf file however is not created, nor are there any tex-temporary files (like *.log or *.aux) created. If I include a 'p.wait()' I see the python.exe and the pdflatex.exe processes are running, but I have it to terminate them manually (they never finish). My system is winXP btw.
Does anyone have an idea what could be wrong? The reason why I want to use the Popen class is because it has the wait() function, so I can wait for the childprocess (pdflatex) to terminate before I start it again (because you need to run pdflatex several times to get all the references/index things correct in the generated pdf).
Thanks for help,
Dominique