Is there a surefire way to import the deadline shipped shotgun_api3 from within a pre/postjob or a render plugin?
I know it’s static dir on the repository, is that always copied over to the render worker, is there a stable way to get this?
Is there a surefire way to import the deadline shipped shotgun_api3 from within a pre/postjob or a render plugin?
I know it’s static dir on the repository, is that always copied over to the render worker, is there a stable way to get this?
Looks like the Shotgun Event plugin does it like this:
def ConfigureShotgun( self ):
shotgunPath = RepositoryUtils.GetAPISyncFolder()
if not os.path.exists( shotgunPath ):
self.LogInfo( "ERROR: Could not find Shotgun API at expected location '%s'" % shotgunPath )
return ""
self.LogInfo( "Importing Shotgun API from '%s'..." % shotgunPath )
if not shotgunPath in sys.path:
sys.path.append( shotgunPath )
try:
#do a test import
import shotgun_api3.shotgun
return shotgunPath
except:
self.LogInfo( "An error occurred while trying to connect to Shotgun:" )
self.LogInfo( traceback.format_exc() )
return ""
The key component seemingly GetAPISyncFolder.
However, if you’re interested in getting updates and whatnot, you might want to lean towards bundling your own: https://github.com/shotgunsoftware/python-api
Cheers