mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
added application action to pype.lib
This commit is contained in:
parent
7f7b220d32
commit
83ac4df7b6
2 changed files with 35 additions and 2 deletions
32
pype/lib.py
32
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
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue