Desktop publisher -- how to know when the last file of multi-file publish is being published

Hi,

I’m wonder if its possible access all files added in desktop publisher within the publish_file.py module.

I’m doing a modification I need to run some code once the last file publishes. Is there a hook that triggers once everything is done? If so is there a way to pass a version id to it?

Thanks!

2 Likes

Hi Simone,

So I’m not the expert here, but we have a post publish phase hook;

There’s a post_publish method which runs after all publishes have completed, and a post_finalize method which runs after everything has completed.

By taking over the post_phase hook (seen here in the publisher app itself: https://github.com/shotgunsoftware/tk-multi-publish2/tree/master/hooks) you can add you logic to one of those 2 methods.

As for the version ID I’m not sure, I might need someone else to chime in there.

4 Likes

What David is suggesting sounds like what you’re after. As for the version ID specifically, if your plugin is creating a Version entity, you could store the resulting version ID back to the item’s properties at publish time. Then you can loop over the items in the post phase hook and extract out the version ID.

1 Like

Thanks! The post_phase hook does what I want.
However per the docs, you can set special keys to the root item and have it process it in the post phase.
This is not what I’m experiencing. I set a key to the root item but in the post_finalize method it does not show that key as existing in the publish_tree.root_item.properties. In fact there are no keys in the root_item, not even path. It’s my understanding that the root item is the first item in the list, no? At any rate, I can’t set a key to it and have it visible in the post hook.
They do show up on the item.properties but not in the root_item.

The workaround is to set my special key to each item but this seems somewhat messy since I only need to set it to the root item.

2 Likes

I think I sorted it out. I had to pass the key to the item’s parent’s properties dictionary.

Thanks again!

4 Likes