I'm trying to run a program and feed the program a script as such:
subprocess.Popen(['X:\\apps\\Nuke6.1v5\\Nuke6.1.exe', '-t', 'X:\\apps\\Scripts\NUKE\\nukeExternalControl\\server.py'])
My problem is that it takes the program a few seconds to finish launching. So while its starting up the program Popen runs the next command and of course because the program is not up and running is errors out. So my question is how do I tell Popen to wait for the first application to run THEN execute the next part of Popen.. any takers??
UPDATE
import nukeExternalControl.client
np = subprocess.Popen(['X:\\apps\\Nuke6.1v5\\Nuke6.1.exe', '-t', 'X:\\apps\\Scripts\NUKE\\nukeExternalControl\\server.py'])
print "Starting Nuke Server"
conn = nukeExternalControl.client.NukeConnection()
nuke = conn.nuke
print "execute commands"
nuke.root().knob('first_frame').setValue(1)
nuke.root().knob('last_frame').setValue(10)
read = nuke.createNode('CheckerBoard2')
textFrame = nuke.createNode('Text')
textShotName = nuke.createNode('Text')
reformat = nuke.createNode('Reformat')
write = nuke.createNode('Write')
SOLUTION
So! Thanks to jdi the problem has been sovled! Props to him as he has stuck this problem out with me for quite some time... thanks so much!
ANSWER:
I needed to use time.sleep()
after the Popen
command because my server was not waiting for nuke to start before communicating to it.