Tank Command for Dev config

Hi Jared

Welcome to the forums, this is a good question.

I’m actually in the middle of writing up a guide that covers exactly this scenario. Unfortunately, that part is not ready to share just yet. However, I can share a snippet of code here.

import sgtk
sgtk.LogManager().initialize_custom_handler()
sgtk.LogManager().global_debug = True

sa = sgtk.authentication.ShotgunAuthenticator()

# Use the authenticator to create a user object. This object
# identifies a Shotgun user or script and also wraps around
# a Shotgun API instance which is associated with that user.
user = sa.create_script_user(api_script="scriptname",
                             api_key="script key",
                             host="https://yoursite.shotgunstudio.com")

sgtk.set_authenticated_user(user)

mgr = sgtk.bootstrap.ToolkitManager()
mgr.plugin_id = "basic.shell"
project = {"type": "Project", "id": 89}

engine = mgr.bootstrap_engine("tk-shell", entity=project)

# # we don't need to do this but it may be useful to see what commands are available
# for command_name, command_dict in engine.commands.items():
#     # print out the command name and the command dictionary
#     print "----------\n%s\n%s" % (command_name, pprint.pformat(command_dict))

# run an app registered with the engine
engine.execute_command("Show Starter Template App...",[])

# get useful API objects from the engine, that you could use for scripting.
tk = engine.sgtk
context = engine.context
sg = engine.shotgun

Let me know if you have any questions around it.
Cheers
Phil

2 Likes