Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for specifying app paths with descriptors #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import tank
from tank import TankError
from tank.descriptor import Descriptor, create_descriptor


class LaunchApplication(tank.platform.Application):
Expand All @@ -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

Expand Down Expand Up @@ -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. """
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -41,6 +47,7 @@ configuration:

linux_path:
type: str
default_value: ""
description: The path to the application executable on Linux.

linux_args:
Expand All @@ -50,6 +57,7 @@ configuration:

mac_path:
type: str
default_value: ""
description: The path to the application executable on Mac OS X.

mac_args:
Expand Down