The reason things work as you expect during the startup sequence is that the plugin path is traversed in reverse order, with init.py/menu.py files exec’ed as they are found. When you call `pluginAddPath`, you’re prepending to the list of plugin paths, but since the list is walked in reverse order, this new file is still in the "queue" of items that will be run. Compare this to calling `pluginAppendPath`, where any init.py/menu.py files in the new path will *not* be evaluated.
"How do I execute init.py and menu.py manually when new plugins are added after nuke has been loaded?" With exec or execfile(). However, there’s no reason you need to put this code in an init.py or menu.py (or even anywhere on the plugin path) if it never gets evaluated during Nuke’s startup sequence. I’m a little confused though... are you trying to alter the available plugins in the middle of a Nuke session, after having potentially already used some of them? What is it that would prevent you from making the appropriate plugins available right out of the gate? -Nathan From: Jesse Kretschmer Sent: Tuesday, October 01, 2013 2:40 PM To: Nuke Python discussion Subject: [Nuke-python] Late loading of init.py and menu.py for plugins Howdy all, I've bee Question How do I execute init.py and menu.py manually when new plugins are added after nuke has been loaded? Background I've been setting up a nuke environment that can dynamically load plugins off the server based on the version of nuke that is being run. This is nearly imperative for quickly swapping plugins on a large farm. My code is working as expected unless I decide to execute it after the nuke UI is fully loaded. Example Code import nuke myPath = "/path/to/nuke/plugin" nuke.pluginAddPath(myPath) As mentioned if this is added to the user init.py or menu.py, any additional menu.py or init.py files will be read and executed. However if I execute this after nuke is fully loaded, the extra init.py and menu.py files are totally ignored. Half-assed workaround To get the functionality that I want, I can manually execfile on any init.py or menu.py file that are found, but it does not seem like the right answer. Example Hack import os import nuke myPath = "/path/to/nuke/plugin" nuke.pluginAddPath(myPath) for x in ['init.py', 'menu.py']: testFile = os.path.join(myPath,x) if os.path.isfile(testFile): execfile(testFile) pass Can anyone offer a better solution? Cheers, Jesse -------------------------------------------------------------------------------- _______________________________________________ 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