I am working on a tool that helps TDs and terminal-accustomed artists to quickly setup a context and start their DCCs from terminal without going through shotgrid desktop. I wanted to add a part where, when they provide the script path, the script automatically opens on startup of nuke.
This is the part of the code that is relevant:
project_id = self.get_project_id_from_name(tmp_show_from_path)
engine = self.get_project_pipeline_tk(project_id)
self.tk = engine.sgtk
if engine:
nuke_script_template = self.tk.template_from_path(arg)
if nuke_script_template:
nuke_script_fields = nuke_script_template.get_fields(arg)
self.do_show(tmp_show_from_path)
self.do_shot(nuke_script_fields.get(“Shot”))
self.do_task(nuke_script_fields.get(“task_name”))
self.do_status(“”)
print(“###############################”, self.context, type(self.context))
print(“###############################”, self.tk, type(self.tk))
launcher = sgtk.platform.create_engine_launcher(self.tk, self.context, “tk-nuke”)
launch_info = launcher.prepare_launch(“/opt/Nuke/Nuke14.0v2/Nuke14.0”, “-x”, os.environ[“QUICKENVSCRIPT”])print(launcher) subprocess.run([f"/opt/Nuke/Nuke14.0v2/Nuke14.0", "-x", f"{os.environ['QUICKENVSCRIPT']}"], env=launch_info.environment)
But I am getting this weird traceback (redacted project specific information):
############################### Comp WIP, Shot {shotcode} <class ‘tank.context.Context’>
############################### Sgtk Core v0.20.22, config {projectroot}/software/shotgrid/shotgrid_configs/{projectname} <class ‘tank.api.Tank’>
Traceback (most recent call last):
File “/home/sadmin/rez/local/quickenv/python/quickenv.py”, line 532, in
qe.cmdloop()
File “/usr/local/lib/python3.9/cmd.py”, line 138, in cmdloop
stop = self.onecmd(line)
File “/home/sadmin/rez/local/quickenv/python/quickenv.py”, line 61, in onecmd
super().onecmd(cmd.strip())
File “/usr/local/lib/python3.9/cmd.py”, line 217, in onecmd
return func(arg)
File “/home/sadmin/rez/local/quickenv/python/quickenv.py”, line 345, in do_script
launcher = sgtk.platform.create_engine_launcher(self.tk, self.context, “tk-nuke”)
File “{projectroot}/software/shotgrid/tk-core/python/tank/platform/software_launcher.py”, line 107, in create_engine_launcher
class_obj = load_plugin(plugin_file, SoftwareLauncher)
File “{projectroot}/software/shotgrid/tk-core/python/tank/util/loader.py”, line 136, in load_plugin
raise TankLoadPluginError(msg)
tank.util.loader.TankLoadPluginError: Error loading the file ‘{projectroot}/software/shotgrid/shotgrid_configs/{projectname}/install/app_store/tk-nuke/v0.14.7/startup.py’. Couldn’t find a single class deriving from ‘SoftwareLauncher’. You need to have exactly one class defined in the file deriving from that base class. If your file looks fine, it is possible that the cached .pyc file that python generates is invalid and this is causing the error. In that case, please delete the .pyc file and try again.
This should be the out of the box install, nobody customized the SoftwareLauncher code, and it also looks like NukeLauncher derives from it correctly (also, deleting .pyc doesn’t change anything, they just get regenerated and I get the same traceback), here’s how the first few lines of startup.py look for me.
import os
import sgtk
import pprintfrom sgtk.platform import SoftwareLauncher, SoftwareVersion, LaunchInformation
class NukeLauncher(SoftwareLauncher):
…
Does anybody know how to help?