Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions hooks/tk-desktop_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Hook that loads defines all the available actions, broken down by publish type.
"""

import os
from typing import Any

import sgtk
Expand Down Expand Up @@ -281,23 +280,6 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None:
else:
raise TankError(f"Invalid entity type for publish: {entity_type}.")

# Use different env var naming for project-level vs task-level contexts
if task_id is not None:
revision_id_env_var = f"TK_FLOWAM_REVISION_ID_{task_id}"
else:
# For project-level contexts, use project ID
project_id = entity_id
revision_id_env_var = f"TK_FLOWAM_REVISION_ID_PROJECT_{project_id}"

if action_name == "publish":
revision_id = sg_publish_data.get("sg_flow_revision_id")
os.environ[revision_id_env_var] = revision_id
else:
# Clear possible previously existing publish states from an unfinished publish
# (Finished publishes should clear this value)
if revision_id_env_var in os.environ:
os.environ.pop(revision_id_env_var)

# NOTE: the context should be either a Task or a Project
entity_ctx = engine.tank.context_from_entity(entity_type, entity_id)

Expand All @@ -307,12 +289,18 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None:
continue
if cmd_settings["properties"]["app"].name == "tk-multi-publish2":
publisher_app = cmd_settings["properties"]["app"]
revision_id = sg_publish_data.get("sg_flow_revision_id")
single_file_mode = (
action_name == "publish"
and publisher_app.context.flow_project_id is not None
)
publisher_app.import_module("tk_multi_publish2").show_dialog(
publisher_app, single_file_mode=single_file_mode
publisher_app,
context=entity_ctx,
root_item_properties=(
{"am_revision_id": revision_id} if revision_id else None
),
single_file_mode=single_file_mode,
)
break
else:
Expand Down