The tk-multi-launchapp is the app that handles the launching of software from Desktop, Shotgun, or Create. The app has a hook called before_app_launch, which, as you might guess from the name, runs just before it launches software, and is often used to set the environment before launching.
You can see that there’s even a commented out example of setting an environment variable in the default hook.
If you’re not familiar with the process of taking over hooks, there’s a very concise walk-through in this post – let me know if you hit any snags, and I can go into more details.
Hope that helps! Let us know if you have any other questions.
The main thing Im trying to do is to set an ocio environment variable with a path to the current project’s ocio config. I had planned to achieve this by creating a text field in the Project entity called colorspace and setting the value to the show working colorspace. If the value was ‘aces’, a bit of python in the before_app_launch hook would set the env variable with the correct path.
I’ve spent a couple of days in the shotgun python API and googling and I have learned that I cannot extract the value, that I enter in the ui, via python as the value is not saved in the schema. Is this correct or am I missing somthing?
I had a look at adding a path in the project’s Pipeline Configuration page but couldn’t work out how to access this with python.
You should be able to use the Shotgun API’s find() or find_one() method to get the value of your custom field from the Project entity. Adding a field to an entity definitely does store the value in your Shotgun database, so I’d be curious to see any documentation that implies otherwise.
I just added a custom field called colorspace to a test project and set its value to ocio; here’s how I got its value (note that Shotgun prepends sg_ to the system names of custom fields):
Thanks Tannaz,
This does make things clear. I did think it odd that values entered in the ui wasn’t accessable via python. I think it came from a blog post and I, obviously, misunderstood something in the API docs.
Thanks again