Looping an executable to get the result from Python script

Posted by fx on Stack Overflow See other posts from Stack Overflow or by fx
Published on 2010-03-20T17:39:42Z Indexed on 2010/03/20 17:41 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

In my python script, I need to call within a for loop an executable, and waiting for that executable to write the result on the "output.xml".

How do I manage to use wait() & how do I know when one of my executable is finished generating the result to get the result? How do I close that process and open a new one to call again the executable and wait for the new result?

    import subprocess
    args = ("bin/bar")
    popen = subprocess.Popen(args)

I need to wait for the output from "bin/bar" to generate the "output.xml" and from there, read it's content.

    for index, result in enumerate(results):
        myModule.callSubProcess(index)
        #this is where the problem is.
        fileOutput = open("output.xml")
        parseAndStoreInSQLiteFileOutput(index, file)

© Stack Overflow or respective owner

Related posts about python

Related posts about system-calls