I'm writing some code that takes a bunch of text files, runs OpinionFinder on them, then analyses the results. OpinionFinder is a python program that calls a java progam to manage various other programs.
I have:
some code (pull data off the web, write text files)
args = shlex.split('python opinionfinder.py -f doclist')
optout = subprocess.Popen(args)
retcode = optout.wait()
some more code to analyse OpinionFinder's text files.
When I didn't have the optout.wait bit, the subprocess 开发者_如何学JAVAwould get executed after the rest of the script had finished, i.e. before the file analysis part. When I added the optout.wait OpinionFinder didn't run properly - I think because it couldn't find the files from the first part of the script - i.e. the order is wrong again.
What am I doing wrong?
What's the best way to run some script, execute an external process, then run the rest of the script?
Thanks.
精彩评论