From caaa341509459e7d839b4422f57bb92857bb89c4 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 18 Nov 2020 19:51:23 +0100 Subject: [PATCH] added application action to launcher tool --- pype/tools/launcher/actions.py | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/pype/tools/launcher/actions.py b/pype/tools/launcher/actions.py index 80e6f71ae7..6603844fa6 100644 --- a/pype/tools/launcher/actions.py +++ b/pype/tools/launcher/actions.py @@ -102,3 +102,53 @@ def register_environment_actions(): module, str(e) ) ) + + +class ApplicationAction(api.Action): + """Pype's application launcher + + Application action based on pype's ApplicationManager system. + """ + + # Application object + application = None + # Action attributes + name = None + label = None + label_variant = None + group = None + icon = None + color = None + order = 0 + + _log = None + required_session_keys = ( + "AVALON_PROJECT", + "AVALON_ASSET", + "AVALON_TASK" + ) + + @property + def log(self): + from pype.api import Logger + if self._log is None: + self._log = Logger().get_logger(self.__class__.__name__) + return self._log + + 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"] + self.application.launch( + project_name=project_name, + asset_name=asset_name, + task_name=task_name + )