Subprocess.popen Command (antiword) Produces Different Output In Shell Vs. Web Application
I have Django running on a standard WSGI/Apache httpd combo. I noticed that file output was different when I ran code in the shell vs. from the browser. I've isolated out everythin
Solution 1:
The difference is likely due to an environment variable. According to the man page:
Antiword uses the environment variables
LC_ALL
,LC_CTYPE
andLANG
(in that order) to get the current locale and uses this information to select the default mapping file.
I suspect that what's happening is that when you run it from your shell, your shell is in a UTF-8 locale, but when you run it from Django, it's in a different locale, and it can't properly convert the Unicode characters. Try switching into a UTF-8 locale when running the subprocess like this:
new_env = dict(os.environ) # Copy current environment
new_env['LANG'] = 'en_US.UTF-8'
p = subprocess.Popen(..., env=new_env)
Post a Comment for "Subprocess.popen Command (antiword) Produces Different Output In Shell Vs. Web Application"