Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. def bootstrap_tank():
  2.  
  3. try:
  4. import tank
  5. except Exception, e:
  6. OpenMaya.MGlobal.displayError("Shotgun: Could not import sgtk! Disabling for now: %s" % e)
  7. return
  8.  
  9. if not "TANK_ENGINE" in os.environ:
  10. OpenMaya.MGlobal.displayError("Shotgun: Missing required environment variable TANK_ENGINE.")
  11. return
  12.  
  13. engine_name = os.environ.get("TANK_ENGINE")
  14. try:
  15. context = tank.context.deserialize(os.environ.get("TANK_CONTEXT"))
  16. print "context: ", context
  17. except Exception, e:
  18. OpenMaya.MGlobal.displayError("Shotgun: Could not create context! Shotgun Pipeline Toolkit will be disabled. Details: %s" % e)
  19. return
  20.  
  21. try:
  22. engine = tank.platform.start_engine(engine_name, context.tank, context)
  23. except Exception, e:
  24. OpenMaya.MGlobal.displayError("Shotgun: Could not start engine: %s" % e)
  25. return
  26.  
  27. file_to_open = os.environ.get("TANK_FILE_TO_OPEN")
  28. if file_to_open:
  29. # finally open the file
  30. cmds.file(file_to_open, force=True, open=True)
  31.  
  32. # clean up temp env vars
  33. for var in ["TANK_ENGINE", "TANK_CONTEXT", "TANK_FILE_TO_OPEN"]:
  34. if var in os.environ:
  35. del os.environ[var]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement