这与我有关系。
我有一幅长篇的文字,在视窗平台上做了一些工作,以制作XML文件,下载一些图像,然后打电话给外部的青.应用,以制作使用Xml的录像,并拍摄出该笔文字的图像。
我向POPen提出的申请,应视其如何解释我通过的数据而恢复现状,即[成功]或[失败]。
如果我用我的代稿生成信息,然后用另一本书把奥塞罗尔应用程序单独称作,那么,它就做了一些出色的工作,我取得了成功,并制作了录像。
成功准则(请 ignore击测试版):
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 ("
----
[" + output + "]
----
")
if output == "[success]":
print "
HURRAHHHHH!!!!!!!"
print ("finished...")
但是,如果在文字末尾加上相同的代码,生成信息,以输入黄色应用,则该编码可操作约2秒和产出=[]。
Same 代码,在不同的文字结尾......
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:
Unhandled Exception: System.IO.IOException: The process cannot access the file
C:videosdatafeed2820712.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)
However I AM closing the file: Extract from the generation script:
xmlfileObj.write( </FeedSettings>
) # 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 ("
----
[" + output + "]
----
")
if output == "[success]":
print "
HURRAHHHHH!!!!!!!"
print ("finished...")
希望得到任何帮助。