From c4d6f2166ce46fb4082d7a4a543af32c8499c312 Mon Sep 17 00:00:00 2001 From: tmosley Date: Mon, 24 Oct 2016 14:25:12 -0700 Subject: [PATCH] Added support for specifying app paths with descriptors To use, specify descriptor settings in 'app_location' attr When use, 'location' key is ignore in favor of values in descriptor settings --- app.py | 22 ++++++++++++++-------- info.yml | 8 ++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 2fc6353..461c82d 100644 --- a/app.py +++ b/app.py @@ -18,6 +18,7 @@ import tank from tank import TankError +from tank.descriptor import Descriptor, create_descriptor class LaunchApplication(tank.platform.Application): @@ -30,9 +31,10 @@ class LaunchApplication(tank.platform.Application): def init_app(self): # get the path setting for this platform: - platform_name = {"linux2": "linux", "darwin": "mac", "win32": "windows"}[sys.platform] - app_path = self.get_setting("%s_path" % platform_name, "") - if not app_path: + self.__app_path = None + + # overrides descriptor, if provided + if not self._get_app_path(): # no application path defined for this os. So don't register a menu item! return @@ -244,10 +246,15 @@ def _apply_version_to_setting(self, raw_string, version=None): def _get_app_path(self, version=None): """ Return the platform specific app path, performing version substitution. """ - platform_name = {"linux2": "linux", "darwin": "mac", "win32": "windows"}[sys.platform] - raw_app_path = self.get_setting("%s_path" % platform_name, "") - - return self._apply_version_to_setting(raw_app_path, version) + if self.__app_path is None: + if self.get_setting("app_location"): + app_descriptor = create_descriptor(self.shotgun, Descriptor.THIRD_PARTY, self.get_setting("app_location")) + self.__app_path = app_descriptor.get_path() + else: + platform_name = {"linux2": "linux", "darwin": "mac", "win32": "windows"}[sys.platform] + raw_app_path = self.get_setting("%s_path" % platform_name, "") + self.__app_path = self._apply_version_to_setting(raw_app_path, version) + return self.__app_path def _get_app_args(self, version=None): """ Return the platform specific app path, performing version substitution. """ @@ -408,7 +415,6 @@ def _launch_app_internal(self, context, file_to_open=None, version=None): "is not set correctly. The command that was used to attempt to launch is '%s'. " "To learn more about how to set up your app launch configuration, " "see the following documentation: %s" % (cmd, self.HELP_DOC_URL)) - else: # Write an event log entry diff --git a/info.yml b/info.yml index f16796c..4487cfa 100644 --- a/info.yml +++ b/info.yml @@ -29,9 +29,15 @@ configuration: the correct operating system separator when used." default_value: "{target_engine}/icon_256.png" + app_descriptor: + type: dict + description: "A dictionary that defines a versioned_path descriptor for finding the app location" + allows_empty: True + # Path information for multiple platforms windows_path: type: str + default_value: "" description: The path to the application executable on Windows. windows_args: @@ -41,6 +47,7 @@ configuration: linux_path: type: str + default_value: "" description: The path to the application executable on Linux. linux_args: @@ -50,6 +57,7 @@ configuration: mac_path: type: str + default_value: "" description: The path to the application executable on Mac OS X. mac_args: