Note that there are some explanatory texts on larger screens.

plurals
  1. POpOpen with python
    primarykey
    data
    text
    <p>This is baffling me.</p> <p>I have a python script that does some work on a Windows platform to generate an XML file, download some images and then call an external console application to generate a video using the xml and images the python script has generated.</p> <p>The application I call with pOPen is supposed to return a status i.e. [success] or [invalid] or [fail] dependant on how it interprets the data I pass it.</p> <p>If I use my generation script to generate the information and then call the console application separately in another script it works fine and I get success and a video is generated.</p> <p>Successful code (please ignore the test prints!):</p> <pre><code>print ("running console app...") cmd = '"C:/Program Files/PropertyVideos/propertyvideos.console.exe" -xml data/feed2820712.xml -mpeg -q normal' print (cmd) p = subprocess.Popen(cmd , stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = p.communicate()[0] print ("\n----\n[" + output + "]\n----\n") if output == "[success]": print "\nHURRAHHHHH!!!!!!!" print ("finished...") </code></pre> <p>But if I include the same code at the end of the script that generates the info to feed the console application then it runs for about 2 seconds and output = []</p> <p>Same code, just ran at the end of a different script...</p> <p>EDIT: Thanks to Dave, Dgrant and ThomasK it seems to be that the generate script is not closing the file as redirecting strerr to stdout shows:</p> <pre><code>Unhandled Exception: System.IO.IOException: The process cannot access the file ' C:\videos\data\feed2820712.xml' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) </code></pre> <p>However I AM closing the file: Extract from the generation script:</p> <pre><code> xmlfileObj.write('&lt;/FeedSettings&gt;\n') # write the last line xmlfileObj.close # sleep to allow files to close time.sleep(10) # NOW GENERATE THE VIDEO print ("initialising video...") cmd = '"C:/Program Files/PropertyVideos/propertyvideos.console.exe" -xml data/feed2820712.xml -mpeg -q normal' print (cmd) p = subprocess.Popen(cmd , stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = p.communicate()[0] print ("\n----\n[" + output + "]\n----\n") if output == "[success]": print "\nHURRAHHHHH!!!!!!!" print ("finished...") </code></pre> <p>Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload