I am trying to use a command line program called foma (http://
code.google.com/p/foma/) from one of my Pylons application's
controllers.  I need to use the program to generate a binary file.
The following Python script generates the file I expect.  This script
opens the foma program and runs two commands: the first loads a human-
readable file ('source phonology.foma') and the second writes the
binary file ('save stack phonology_bin.foma').

import subprocess
process = subprocess.Popen(['foma'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
result = process.communicate('source phonology.foma\nsave stack
phonology_bin.foma\n')[0]

However, if I run the exact same three lines of code *from within* a
Pylons controller, a phonology_bin.foma file is still generated but it
is not the file I expect.

Note that the incorrect/unexpected binary file generated *is* a valid
foma file, it is just not the one I expect, i.e., it is not the one
generated by running the Python script from the command line.

Can somebody enlighten me as to what might be the cause of this
discrepancy?

Or (perhaps better) could someone point me towards a better strategy
for solving this problem?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to