I’ve found this topic on shotgun support from 2015 which shows how to run tank updates command via tk-core but, unfortunately, it’s not exactly what I need. I’m looking for ways to do non-interactive dry-runs basically, generating a report without actually updating anything.
From what I found so far (reading through the code), there is no easy way to do this without re-implementing the “updates” command.
I’ve already accepted this and started working on it, but just in case someone has already tried something like this and has a better idea, I’d be quite thankful to hear it.
Yeah I think you’re correct there would be no easy way to do a dry run.
One thing you could do, that might be easier to implement, is have your tool copy the config to a temporary location, then run the updates on that, and perform a diff between the two and clear out the temp config.
This might help:
# Get the command for updating configs, from the sgtk instance
core_cmd = tk.get_command("updates")
# Now update an external config in thee given path
Thanks for the answer and the suggestion. I’ve seen this option and considered it, but deemed it … inelegant. Perhaps not very wisely, though… Having to maintain the update analysis code ourselves when otherwise avoidable is also not ideal. Well, I’ll see.
Thanks in any case!
Yeah thats fair enough, I agree its not an elegant solution, though in my personal opinion, I guess I would prefer it to having to maintain the update code. I don’t think there is a wrong or right answer here.
That said I’ll pop an idea suggestion into our roadmap page on your behalf.
I have another idea, which I’ve not tried and would be quite inelegant as well
Use subprocess to call the tank command file and the comunicate back with it. Say “no” to all updates but read the output, and parse it into a list of bundles that need updating.
I don’t think this snippet works, I’ve not tested but, something like this:
tank_cmd = "/sg_toolkit/configs/my_config/tank"
p = subprocess.Popen([tank_cmd,"updates"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# now communicate the 2 args
Very good but it still requires some (potential) maintenance on the parsing side (if you guys change the stdout stuff and so on). But, nice to have options. Thanks, Philip!