Hello!
I'm sorry if this is a duplicate question, but after searching through 3 pages for "django subprocess", I, for one, could not find the answer to my particular problem.
I'm trying to run pdflatex
on tex
file, but for some reason in Django it doesn't produce anything. It works just fine in a regular python script, though. I've omitted most of the code here, but this is basically the important bit. I'm running this on apache2 with mod_wsgi, and I suspect that it might be an apache permissions related problem, dunno though.
Thanks in advance.
import subprocess
test = subprocess.Popen(['pdflatex','/home/sheepz/test.tex'],shell=True, stdout=subprocess.PIPE)
log = open('/home/sheepz/log.log', 'w')
log.write(str(test.communicate()))
log.close()
the content of the file "log.log":
('This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)\n restricted \\write18 enabled.\n**\n! End of file on the terminal... why?\n', None)
EDIT: The solution for this issue is quite easy. I just want to add it here, so everyone who's having trouble with this, can find it. Basically it involves running the site as a different user rather than www-data using the WSGIDaemonProcess configuration directive. Here is a minimal configuration:
ServerName www.mysite.com
ServerAlias *mysite.com
WSGIDaemonProcess www.mysite.com user=joe group=joe home=/home/joe/
WSGIProcessGroup www.mysite.com
Also, it would be advisable to add WSGIRestrictStdout Off
to your httpd.conf, because, as far as I understand, mod_wsgi ignores any process that tries to use stdout. Thanks, Graham.