Geniuses! Thanks, as always, Ben and Nathan. Got it working.
den serras @ stereoD -----Original Message----- From: nuke-python-boun...@support.thefoundry.co.uk [mailto:nuke-python-boun...@support.thefoundry.co.uk] On Behalf Of Nathan Rusch Sent: Wednesday, September 18, 2013 7:44 PM To: Nuke Python discussion Subject: Re: [Nuke-python] Launch a totally new Nuke process... From insideNuke Yeah, that's a possibility as well, but then you're left in a tough spot: You have to either A) start from the running process' environment and sanitize it down to something generic *enough*, or B) build up a new environment from scratch. Neither approach is great, but I suppose if you know which environment variables you'll be needing to set, you could pop them out of a copy of os.environ and then pass that to your subprocess. Or, if you wanted to try building one up from scratch, you could probably inspect the registry to get all of the system- and user-level variables that would be set in a default shell environment, or just make some assumptions and set or copy specific values from the current process' environment. -Nathan -----Original Message----- From: Ben Dickson Sent: Wednesday, September 18, 2013 7:17 PM To: Nuke Python discussion Subject: Re: [Nuke-python] Launch a totally new Nuke process... From insideNuke Windows might be slightly different in this regard, but on OS X/Linux the environment variables like NUKE_PATH will be inherited by the child process. To start the process in a clean environment, you would do this: subprocess.Popen(args, env={}) or: subprocess.Popen(args, env={ 'CONFIG_THING': os.getenv("CONFIG_THING"), ...}) On 19/09/13 11:39, Dennis Serras wrote: > Unfortunately, that still doesn't work - it still considers the > packages loaded in the initial Nuke install to be loaded already, so > won't load different packages. What I need is for it to behave as if I > created a totally new console and typed in the launch commands; even > though this creates a new CMD window, it behaves as if it were an > extension of the same cmd that launched Nuke initially. Maybe I need a > different approach... > > *den serras * > > @ stereoD > > *From:*nuke-python-boun...@support.thefoundry.co.uk > [mailto:nuke-python-boun...@support.thefoundry.co.uk] *On Behalf Of > *Nathan Rusch > *Sent:* Tuesday, September 17, 2013 9:38 AM > *To:* Nuke Python discussion > *Subject:* Re: [Nuke-python] Launch a totally new Nuke process... From > inside Nuke > > 'start' works fine with 'cmd', but it isn't an executable, so you have > to run it... through cmd again. You should be using subprocess.Popen > instead of os.system though: > > args = ['cmd', '/C', 'start', 'cmd', '/K', > os.path.normpath(nuke.env['ExecutablePath'])] > > if nuke.env['nukex']: > > args.append('--nukex') > > subprocess.Popen(args) > > -Nathan > > *From:*Dennis Serras <mailto:dennis.ser...@bydeluxe.com> > > *Sent:*Monday, September 16, 2013 6:38 PM > > *To:*nuke-python@support.thefoundry.co.uk > <mailto:nuke-python@support.thefoundry.co.uk> > > *Subject:*[Nuke-python] Launch a totally new Nuke process... From > inside Nuke > > Having fun trying to launch Nuke from Nuke. We have a custom Windows > command line launch system that handles all the packages, versions, > licensing, etc.; it's based on subprocess.Popen. I'm building a tool > that allows launching of a script with a different build and/or > package of Nuke. When I use the usual culprits (subprocess.call, > subprocess.Popen, os.popen, etc.) they all want to launch a new Nuke > in the same cmd window and with the same setup as the current one - if > I use any other setup it fails. So I figured I need to launch from a > new cmd window - so tried os.system("start cmd /K blahblah"), and > os.startfile("blahblah.bat") which created a new cmd window - but it > still has the same problem. Of course if I use cmd directly I can > launch as many different versions of Nuke as I have licenses free. Any > ideas how I can do this? > > Thanks! > > Den > > *den serras* > > @ > > senior technical artist | *stereo D*| deluxe 3D > > > This e-mail and any attachments are intended only for use by the > addressee(s) named herein and may contain confidential information. If > you are not the intended recipient of this e-mail, you are hereby > notified any dissemination, distribution or copying of this email and > any attachments is strictly prohibited. If you receive this email in > error, please immediately notify the sender by return email and > permanently delete the original, any copy and any printout thereof. > The integrity and security of e-mail cannot be guaranteed. > > ---------------------------------------------------------------------- > -- > > _______________________________________________ > Nuke-python mailing list > Nuke-python@support.thefoundry.co.uk > <mailto:Nuke-python@support.thefoundry.co.uk>, > http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > > > This e-mail and any attachments are intended only for use by the > addressee(s) named herein and may contain confidential information. If > you are not the intended recipient of this e-mail, you are hereby > notified any dissemination, distribution or copying of this email and > any attachments is strictly prohibited. If you receive this email in > error, please immediately notify the sender by return email and > permanently delete the original, any copy and any printout thereof. > The integrity and security of e-mail cannot be guaranteed. > > > _______________________________________________ > Nuke-python mailing list > Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python -- ben dickson 2D TD | ben.dick...@rsp.com.au rising sun pictures | www.rsp.com.au _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python This e-mail and any attachments are intended only for use by the addressee(s) named herein and may contain confidential information. If you are not the intended recipient of this e-mail, you are hereby notified any dissemination, distribution or copying of this email and any attachments is strictly prohibited. If you receive this email in error, please immediately notify the sender by return email and permanently delete the original, any copy and any printout thereof. The integrity and security of e-mail cannot be guaranteed. _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python