Sorry, I guess you’re using the forums exclusively... I was talking about my previous reply to the mailing list, which should have shown up on the forum as well.
>From your code, it looks like you may be using a centralized install of Nuke, >so you may be right that the first load of Nuke is slow enough that the server >isn’t set up by the time the client tries to connect to it. The other thing to keep in mind is that the child process will not die when your script terminates, so you’ll need to handle this yourself. In your case, what may be happening is that the orphaned Nuke process from the first run of your script is still alive in the background, and the second time the client is run, it is actually connecting to the old Nuke instance. However, this means it’s also spawning another Nuke instance that will again be hanging around in the background... In the nukeExternalControl.client module, you’ll find another class we contributed that sets up a managed server-client pair transparently in the context of a with statement, and then shuts the Nuke process down when the "with" block exits. However, it has only been tested on Linux to this point, and at some point it will likely be changed (per feedback) to operate as a subclass of NukeConnection instead of a special-case handler (to facilitate easier use in interactive terminals). Regardless, it should at least provide a decent example of what situations you need to consider and handle to reliably manage a separate non-blocking subprocess that cannot respond to standard input. -Nathan From: Manley Sent: Tuesday, February 28, 2012 1:35 PM To: [email protected] Subject: [Nuke-python] Re: Nuke Module External Python Shell Sorry NathanR, I didn't get that. You sent me a pm? :S I took the "shell=True" out and ran the script but it did the same thing.. HOWEVER.. I did discover that if I run the script once it errors out like nornal... but if I run the script again in the same python shell it works!! So my thought it that because it takes a few seconds to start nuke the python script is trying to run the next part(nukeExternalControl\server.py) and is not finding Nuke.. So now I'm trying to find a way to tell Popen to first start nuke and wait till its done then run the server.. If you know how to do that please let me know and if not thank you a TON for your help Many thanks, Manley NathanR wrote: There is a reason I removed the "shell=True" kwarg from your Popen call in my previous email... The following code works fine (assuming you have all the necessary modules/packackes on your system PYTHONPATH, and you change the paths in the subprocess call appropriately): import subprocess import nukeExternalControl.client print "Starting Nuke Server" np = subprocess.Popen(["C:\\Path\\To\\Nuke\\Nuke6.3.exe", '-t', "C:\\Path\\To\\PythonPath\\nukeExternalControl\\server.py"]) conn = nukeExternalControl.client.NukeConnection() nuke = conn.nuke print "execute commands" nuke.root().knob('first_frame').setValue(1) nuke.root().knob('last_frame').setValue(10) If it doesn’t, your firewall is probably blocking the port it’s trying to use. -Nathan From: Manley ([email protected]) Sent: Monday, February 27, 2012 5:38 PM To: [email protected] ([email protected]) Subject: [Nuke-python] Re: Nuke Module External Python Shell The python script is as such: np = subprocess.Popen(['X:\\apps\\Nuke6.1v5\\Nuke6.1.exe', '-t', r'X:\apps\Scripts\NUKE\nukeExternalControl\server.py'], shell=True) print "Starting Nuke Server" import nukeExternalControl.client conn = nukeExternalControl.client.NukeConnection() nuke = conn.nuke print "execute commands" nuke.root().knob('first_frame').setValue(1) nuke.root().knob('last_frame').setValue(10) The error I'm getting is this: ['eur512_029_040_031(dpx) 1-1', 'eur512_029_040_031(jpg) 1-10'] Running Nuke Starting Nuke Server Nuke 6.1v5, 64 bit, built Feb 11 2011. Copyright (c) 2010 The Foundry Visionmongers Ltd. All Rights Reserved. SERVER: Checking port 54200 Exception in Tkinter callback Traceback (most recent call last): File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__ return self.func(*args) File "C:\Users\manley\Desktop\man\testCapture.py", line 338, in runNuke conn = nukeExternalControl.client.NukeConnection() File "C:\Python27\nukeExternalControl\client.py", line 45, in __init__ raise NukeConnectionError("Connection with Nuke failed") NukeConnectionError: Connection with Nuke failed -------------------------------------------------------------------------------- _______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
