1212Hook that loads defines all the available actions, broken down by publish type.
1313"""
1414
15- import os
1615from typing import Any
1716
1817import sgtk
@@ -245,23 +244,6 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None:
245244 else :
246245 raise TankError (f"Invalid entity type for publish: { entity_type } ." )
247246
248- # Use different env var naming for project-level vs task-level contexts
249- if task_id is not None :
250- revision_id_env_var = f"TK_FLOWAM_REVISION_ID_{ task_id } "
251- else :
252- # For project-level contexts, use project ID
253- project_id = entity_id
254- revision_id_env_var = f"TK_FLOWAM_REVISION_ID_PROJECT_{ project_id } "
255-
256- if action_name == "publish" :
257- revision_id = sg_publish_data .get ("sg_flow_revision_id" )
258- os .environ [revision_id_env_var ] = revision_id
259- else :
260- # Clear possible previously existing publish states from an unfinished publish
261- # (Finished publishes should clear this value)
262- if revision_id_env_var in os .environ :
263- os .environ .pop (revision_id_env_var )
264-
265247 # NOTE: the context should be either a Task or a Project
266248 entity_ctx = engine .tank .context_from_entity (entity_type , entity_id )
267249
@@ -277,15 +259,12 @@ def _launch_publisher(self, action_name: str, sg_publish_data: dict) -> None:
277259 "env/includes/desktop/project.yml under 'desktop.project: apps:'\n \n "
278260 )
279261
280- try :
281- # Set context and launch Publisher using the pre-imported module
282- publisher_app ._set_context (entity_ctx )
283-
284- # For republish action, restrict publisher to single file mode
285- single_file_mode = action_name == "publish"
286- publisher_app .show_publish_dialog (single_file_mode = single_file_mode )
287- except Exception as e :
288- raise TankError (
289- f"Failed to launch Publisher: { e } \n \n "
290- f"The Publisher app was found but failed to start."
291- )
262+ tk_multi_publish2 = publisher_app .import_module ("tk_multi_publish2" )
263+ revision_id = sg_publish_data .get ("sg_flow_revision_id" )
264+ tk_multi_publish2 .show_dialog (
265+ publisher_app ,
266+ context = entity_ctx ,
267+ root_item_properties = (
268+ {"am_revision_id" : revision_id } if revision_id else None
269+ ),
270+ )
0 commit comments