Snippet media context path
py
import pipelineLib
media_path = r"<FILEPATH_HERE>"
api = pipelineLib.instance()
def get_version_name_from_context(context):
data = [
context.get("entity.code"),
context.get("task.code"),
context.get("branch"),
"v%03d" % context.get("version") if context.get("version") else None,
]
return "-".join(filter(None, data))
with api.inContext(media_path) as context:
print(context)
data = {
"project": context["project"],
"entity": context["entity"],
"code": get_version_name_from_context(context),
}
if "task" in context:
data["task"] = context["task"]
print("-" * 80)
print(data)
project = data["project"]
entity = data["entity"]
task = data["task"]
print(project)
print(entity)
print(task)
sg = api.shotgun
sg_tasks = sg.find(
"Task",
[
["project", "is", project], # doesn't work, context incompatible between ada/shotgun, just for example
["entity", "is", entity],
["content", "is", task["code"]],
],
["content"],
)
print(sg_tasks)