mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge branch 'develop' into enhancement/1416-loader-actions
This commit is contained in:
commit
ce3a59446c
27 changed files with 768 additions and 140 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from .constants import ContextChangeReason
|
||||
from .abstract import AbstractHost
|
||||
from .abstract import AbstractHost, ApplicationInformation
|
||||
from .host import (
|
||||
HostBase,
|
||||
ContextChangeData,
|
||||
|
|
@ -21,6 +21,7 @@ __all__ = (
|
|||
"ContextChangeReason",
|
||||
|
||||
"AbstractHost",
|
||||
"ApplicationInformation",
|
||||
|
||||
"HostBase",
|
||||
"ContextChangeData",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import logging
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
import typing
|
||||
from typing import Optional, Any
|
||||
|
||||
|
|
@ -13,6 +14,19 @@ if typing.TYPE_CHECKING:
|
|||
from .typing import HostContextData
|
||||
|
||||
|
||||
@dataclass
|
||||
class ApplicationInformation:
|
||||
"""Application information.
|
||||
|
||||
Attributes:
|
||||
app_name (Optional[str]): Application name. e.g. Maya, NukeX, Nuke
|
||||
app_version (Optional[str]): Application version. e.g. 15.2.1
|
||||
|
||||
"""
|
||||
app_name: Optional[str] = None
|
||||
app_version: Optional[str] = None
|
||||
|
||||
|
||||
class AbstractHost(ABC):
|
||||
"""Abstract definition of host implementation."""
|
||||
@property
|
||||
|
|
@ -26,6 +40,16 @@ class AbstractHost(ABC):
|
|||
"""Host name."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_app_information(self) -> ApplicationInformation:
|
||||
"""Information about the application where host is running.
|
||||
|
||||
Returns:
|
||||
ApplicationInformation: Application information.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_current_context(self) -> HostContextData:
|
||||
"""Get the current context of the host.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import ayon_api
|
|||
from ayon_core.lib import emit_event
|
||||
|
||||
from .constants import ContextChangeReason
|
||||
from .abstract import AbstractHost
|
||||
from .abstract import AbstractHost, ApplicationInformation
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from ayon_core.pipeline import Anatomy
|
||||
|
|
@ -96,6 +96,18 @@ class HostBase(AbstractHost):
|
|||
|
||||
pass
|
||||
|
||||
def get_app_information(self) -> ApplicationInformation:
|
||||
"""Running application information.
|
||||
|
||||
Host integration should override this method and return correct
|
||||
information.
|
||||
|
||||
Returns:
|
||||
ApplicationInformation: Application information.
|
||||
|
||||
"""
|
||||
return ApplicationInformation()
|
||||
|
||||
def install(self):
|
||||
"""Install host specific functionality.
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class _WorkfileOptionalData:
|
|||
):
|
||||
if kwargs:
|
||||
cls_name = self.__class__.__name__
|
||||
keys = ", ".join(['"{}"'.format(k) for k in kwargs.keys()])
|
||||
keys = ", ".join([f'"{k}"' for k in kwargs.keys()])
|
||||
warnings.warn(
|
||||
f"Unknown keywords passed to {cls_name}: {keys}",
|
||||
)
|
||||
|
|
@ -1554,6 +1554,27 @@ class IWorkfileHost(AbstractHost):
|
|||
if platform.system().lower() == "windows":
|
||||
rootless_path = rootless_path.replace("\\", "/")
|
||||
|
||||
# Get application information
|
||||
app_info = self.get_app_information()
|
||||
data = {}
|
||||
if app_info.app_name:
|
||||
data["app_name"] = app_info.app_name
|
||||
if app_info.app_version:
|
||||
data["app_version"] = app_info.app_version
|
||||
|
||||
# Use app group and app variant from applications addon (if available)
|
||||
app_addon_name = os.environ.get("AYON_APP_NAME")
|
||||
if not app_addon_name:
|
||||
app_addon_name = None
|
||||
|
||||
app_addon_tools_s = os.environ.get("AYON_APP_TOOLS")
|
||||
app_addon_tools = []
|
||||
if app_addon_tools_s:
|
||||
app_addon_tools = app_addon_tools_s.split(";")
|
||||
|
||||
data["ayon_app_name"] = app_addon_name
|
||||
data["ayon_app_tools"] = app_addon_tools
|
||||
|
||||
workfile_info = save_workfile_info(
|
||||
project_name,
|
||||
save_workfile_context.task_entity["id"],
|
||||
|
|
@ -1562,6 +1583,7 @@ class IWorkfileHost(AbstractHost):
|
|||
version,
|
||||
comment,
|
||||
description,
|
||||
data=data,
|
||||
workfile_entities=save_workfile_context.workfile_entities,
|
||||
)
|
||||
return workfile_info
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue