I use libreoffice in the CLI to convert some documents to PDF files in Django.
This is in my opinion (and also tried in the save method on the model):
outdir = '/'.join([settings.MEDIA_ROOT, 'pdf']) command = ['libreoffice', '--headless', '--convert-to', 'pdf', '-outdir', outdir, form.instance.upload.path] stdout, stderr = subprocess.Popen(command).communicate()
I also tried the following instead of subprocess.Popen :
os.system("libreoffice --headless --convert-to pdf --outdir %s %s" % (outdir, instance.upload.path))
Then I check:
# quick check new file exists with open("%s/%s.pdf" % (outdir, os.path.splitext(instance.upload.name)[0])): pass
When I run them through the website, it just doesn't work - the PDF file is not created.
The thing is: both of these methods work both in my local environment and when the functions in which they are located are called from $ python manage.py shell
The only problem is production.
- Django 1.4
- Python 2.7.3
- Server Version: Apache / 2.2.22 (Ubuntu) Server Built: February 13, 2012 01:51:50 (Rackspace)
Notice that I thought I might be experiencing this error: Popen no longer works with apache / wsgi and python 2.7.2? ...
Although Graham works as follows (I added this to my apache2.conf ), it seems nothing changes.
WSGIApplicationGroup %{GLOBAL}
My sys administration skills are small, although I may have done it wrong and I'm completely at a standstill, any advice or directions about other things to try or think about will be appreciated.