Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird subprocess issue with Django
    text
    copied!<p>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. </p> <p>I'm trying to run <code>pdflatex</code> on <code>tex</code> 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.</p> <pre><code>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) </code></pre> <p>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 <a href="http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess" rel="nofollow noreferrer">WSGIDaemonProcess</a> configuration directive. Here is a minimal configuration:</p> <pre><code>ServerName www.mysite.com ServerAlias *mysite.com WSGIDaemonProcess www.mysite.com user=joe group=joe home=/home/joe/ WSGIProcessGroup www.mysite.com </code></pre> <p>Also, it would be advisable to add <code>WSGIRestrictStdout Off</code> to your httpd.conf, because, as far as I understand, mod_wsgi ignores any process that tries to use stdout. Thanks, Graham.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload