Jorey Bump
list at joreybump.com
Wed Oct 19 20:40:06 EDT 2005
G.M.Dall'Olio wrote: > The problem is that this code returns 'None'; because the graph is drawn > on stdout, and not returned. > So I'm trying to find a way to take stdout in the script, but I receive > security errors from apache. Have you investigated the os.popen* variants? It might be easiest to create a command line script that does what you want and open it for reading & writing. I do this with some proprietary binaries used on one of my sites. Here's an example (your needs will differ a bit): import os def client_query(client, arg1, arg2, arg3): """ Pass arguments to a client command and collect combined stdout & stderr into a list of lines. client: full path to executable script or binary """ cmd = "%s %s %s %s" % (client, arg1, arg2, arg3) # os.popen4 combines stdout & stderr for reading w, r = os.popen4(cmd) client_response = r.readlines() r.close() w.close() return client_response
|