I have a problem with opening PDF file.
(i am using Ladon and Python under mod_wsgi working with Apache2. so on a ubuntu apache server system- switched to windows system)
I'm trying to run the following Python script:
(where, str_pdf_file_name = '/var/www/Accounting_Engine/pdfDocuments/File_name.pdf'
)
def preview_pdf(self,str_pdf_file_name):
try:
if sys.version_info[:2] > (2,3):
import subprocess
from subprocess import Popen, PIPE
k = subprocess.Popen(['evince', str_pdf_file_name],stdout=PIPE)
print k.communicate()
else:
os.spawnlp(os.P_NOWAIT, 'evince', 'evince', str_pdf_file_name)
except Exception,msg:
return str(msg)
return str_pdf_file_name
I have disabled the stdin and stdout restrictions in apache2.conf file as
WSGIRestrictStdin Off
WSGIRestrictStdout Off
and now the error.log file shows (/var/log/apache2/error.log
):
Cannot parse arguments: Cannot open display: [Wed Oct 10 11:50:24 2012] [error] ('', None)
I have checked os.environ also. It shows like:
{'LANG': 'C', 'APACHE_RUN_USER': 'www-data', 'APACHE_PID_FILE': '/var/run/apache2.pid', 'PWD': '/home/user', 'APACHE_RUN_GROUP': 'www-data', 'PATH': '/usr/local/bin:/usr/bin:/bin'}
I have also tried by changing the PWD by using the following codes:
import pwd
os.environ["PWD"] = pwd.getpwuid(os.getuid()).pw_dir # Because PWD of 'www-data' was '/var/www'
k = subprocess.Popen(['evince', str_pdf_file_name],env=os.environ,stdout=PIPE)
But their is no change in output. It still shows
'Cannot parse arguments: Cannot open display:'
Any suggestions what could be the cause and how to solve this?