diff --git a/pype/lib.py b/pype/lib.py index ff0c0c0e82..46dd2b781d 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -1590,3 +1590,35 @@ def launch_application(project_name, asset_name, task_name, app_name): "/usr/bin/env", args=["bash", execfile], environment=env ) return popen + + +class ApplicationAction(avalon.api.Action): + """Default application launcher + + This is a convenience application Action that when "config" refers to a + parsed application `.toml` this can launch the application. + + """ + + config = None + required_session_keys = ( + "AVALON_PROJECT", + "AVALON_ASSET", + "AVALON_TASK" + ) + + def is_compatible(self, session): + for key in self.required_session_keys: + if key not in session: + return False + return True + + def process(self, session, **kwargs): + """Process the full Application action""" + + project_name = session["AVALON_PROJECT"] + asset_name = session["AVALON_ASSET"] + task_name = session["AVALON_TASK"] + return launch_application( + project_name, asset_name, task_name, self.name + ) diff --git a/pype/tools/launcher/lib.py b/pype/tools/launcher/lib.py index 0bbbb55560..027ae96e84 100644 --- a/pype/tools/launcher/lib.py +++ b/pype/tools/launcher/lib.py @@ -16,9 +16,10 @@ provides a bridge between the file-based project inventory and configuration. import os from Qt import QtGui -from avalon import lib, pipeline +from avalon import lib from avalon.vendor import qtawesome from pype.api import resources +from pype.lib import ApplicationAction ICON_CACHE = {} NOT_FOUND = type("NotFound", (object, ), {}) @@ -52,7 +53,7 @@ def get_application_actions(project): action = type( "app_{}".format(app_name), - (pipeline.Application,), + (ApplicationAction,), { "name": app_name, "label": label,