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

hookify software_entity_launcher and single_config_launcher #82

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
21 changes: 13 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ def init_app(self):
# Use the Launchers defined in the tk_multi_launchapp payload
# to do all of the heavy lifting for this app
app_payload = self.import_module("tk_multi_launchapp")
if self.get_setting("use_software_entity"):
# For zero config type setups
self._launcher = app_payload.SoftwareEntityLauncher()
else:
# For traditional setups
self._launcher = app_payload.SingleConfigLauncher()

# Register the appropriate DCC launch commands
# if self.get_setting("use_software_entity"):
# # For zero config type setups
# self._launcher = app_payload.SoftwareEntityLauncher()
# else:
# # For traditional setups
# self._launcher = app_payload.SingleConfigLauncher()

self._launcher = self.execute_hook_method(
"hook_launcher", "init", base_class=app_payload.BaseLauncher
)

# # Register the appropriate DCC launch commands

self._launcher.register_launch_commands()

def launch_from_path_and_context(self, path, context, version=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,30 @@
import sgtk
from sgtk import TankError

from .base_launcher import BaseLauncher
HookBaseClass = sgtk.get_hook_baseclass()


class SingleConfigLauncher(BaseLauncher):
class SingleConfigLauncher(HookBaseClass):
"""
Launches a DCC based on traditional configuration settings.
"""

def __init__(self):
def init(self):
"""
Initialize base class and member values
"""
BaseLauncher.__init__(self)

super(SingleConfigLauncher, self).init()

# Store required information to launch the app as members.
self._app_path = self._tk_app.get_setting("%s_path" % self._platform_name, "")
self._app_args = self._tk_app.get_setting("%s_args" % self._platform_name, "")
self._app_menu_name = self._tk_app.get_setting("menu_name")
self._app_engine = self._tk_app.get_setting("engine")
self._app_group = self._tk_app.get_setting("group")
self._is_group_default = self._tk_app.get_setting("group_default")
self._app_path = self.parent.get_setting("%s_path" % self._platform_name, "")
self._app_args = self.parent.get_setting("%s_args" % self._platform_name, "")
self._app_menu_name = self.parent.get_setting("menu_name")
self._app_engine = self.parent.get_setting("engine")
self._app_group = self.parent.get_setting("group")
self._is_group_default = self.parent.get_setting("group_default")

return self

def register_launch_commands(self):
"""
Expand All @@ -46,11 +49,11 @@ def register_launch_commands(self):
return

# get icon value, replacing tokens if needed
app_icon = self._tk_app.get_setting("icon")
app_icon = self.parent.get_setting("icon")
if app_icon.startswith("{target_engine}"):
if self._app_engine:
engine_path = sgtk.platform.get_engine_path(
self._app_engine, self._tk_app.sgtk, self._tk_app.context
self._app_engine, self.parent.sgtk, self.parent.context
)
if engine_path:
app_icon = app_icon.replace("{target_engine}", engine_path, 1)
Expand All @@ -65,7 +68,7 @@ def register_launch_commands(self):
app_icon = ""

if app_icon.startswith("{config_path}"):
config_path = self._tk_app.sgtk.pipeline_configuration.get_config_location()
config_path = self.parent.sgtk.pipeline_configuration.get_config_location()
if not config_path:
raise TankError(
"No pipeline configuration path found for '{config_path}' replacement."
Expand All @@ -76,13 +79,13 @@ def register_launch_commands(self):
app_icon = app_icon.replace("/", os.path.sep)

# Initialize per version
app_versions = self._tk_app.get_setting("versions") or []
app_versions = self.parent.get_setting("versions") or []
if app_versions:
# If a list of versions has been specified, the "group_default" configuration
# setting is invalid because it cannot be applied to each generated command.
# Set the group default to the highest version in the list instead.
sorted_versions = self._sort_versions(app_versions)
self._tk_app.log_debug(
self.parent.log_debug(
"Unable to apply group '%s' group_default value to list of DCC versions : %s. "
"Setting group '%s' default to highest version '%s' instead."
% (
Expand Down Expand Up @@ -131,7 +134,7 @@ def launch_from_path(self, path, version=None):
:param path: File path DCC should open after launch.
:param version: (Optional) Specific version of DCC to launch.
"""
context = self._tk_app.sgtk.context_from_path(path)
context = self.parent.sgtk.context_from_path(path)
self._launch_app(
self._app_menu_name,
self._app_engine,
Expand Down
Loading