I am trying to convert a PDF to a JPG/PNG via Wand.
This is the code (edit)
os.path.isfile(os.path.join(settings.PROJECT_PATH, "file.pdf"):
with Image(filename=os.path.join(settings.PROJECT_PATH, "file.pdf", resolution=100) as image:
image.save(filename=os.path.join(settings.PROJECT_PATH, "file.jpg")
It works perfectly on the local dev server, the dev server on the production server, and also in the manage.py shell (on production server) .
However, when using via my production supervisor/guncicorn setup, I get the following error
DelegateError at /finance/api/v1/receipt/
Postscript delegate failed `/webapps/bab/bab/Beenie-Man-1.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/677
This is the startupscript.
#!/bin/bash
NAME="bab" # Name of the application
DJANGODIR=/webapps/bab/bab # Django project directory
SOCKFILE=/webapps/bab/run/gunicorn.sock # we will communicte using this unix socket
USER=bab # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=1 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bab.settings # which settings file should Django use
DJANGO_WSGI_MODULE=bab.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILEchris@python:/webapps/bab$
When I was running the tests on the production server, with both running the full debug server & the shell, it was being run with the correct user account & correct virtualenv (not that it would work at all without that)
Could it be an environment variable issue though? Or some kind of permission thing?