mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Converted push to project plugin
This commit is contained in:
parent
f784eeb17e
commit
2a13074e6b
2 changed files with 73 additions and 51 deletions
|
|
@ -1,51 +0,0 @@
|
|||
import os
|
||||
|
||||
from ayon_core import AYON_CORE_ROOT
|
||||
from ayon_core.lib import get_ayon_launcher_args, run_detached_process
|
||||
from ayon_core.pipeline import load
|
||||
from ayon_core.pipeline.load import LoadError
|
||||
|
||||
|
||||
class PushToProject(load.ProductLoaderPlugin):
|
||||
"""Export selected versions to different project"""
|
||||
|
||||
is_multiple_contexts_compatible = True
|
||||
|
||||
representations = {"*"}
|
||||
product_types = {"*"}
|
||||
|
||||
label = "Push to project"
|
||||
order = 35
|
||||
icon = "send"
|
||||
color = "#d8d8d8"
|
||||
|
||||
def load(self, contexts, name=None, namespace=None, options=None):
|
||||
filtered_contexts = [
|
||||
context
|
||||
for context in contexts
|
||||
if context.get("project") and context.get("version")
|
||||
]
|
||||
if not filtered_contexts:
|
||||
raise LoadError("Nothing to push for your selection")
|
||||
|
||||
if len(filtered_contexts) > 1:
|
||||
raise LoadError("Please select only one item")
|
||||
|
||||
context = tuple(filtered_contexts)[0]
|
||||
|
||||
push_tool_script_path = os.path.join(
|
||||
AYON_CORE_ROOT,
|
||||
"tools",
|
||||
"push_to_project",
|
||||
"main.py"
|
||||
)
|
||||
|
||||
project_name = context["project"]["name"]
|
||||
version_id = context["version"]["id"]
|
||||
|
||||
args = get_ayon_launcher_args(
|
||||
push_tool_script_path,
|
||||
"--project", project_name,
|
||||
"--version", version_id
|
||||
)
|
||||
run_detached_process(args)
|
||||
73
client/ayon_core/plugins/loader/push_to_project.py
Normal file
73
client/ayon_core/plugins/loader/push_to_project.py
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import os
|
||||
from typing import Optional, Any
|
||||
|
||||
from ayon_core import AYON_CORE_ROOT
|
||||
from ayon_core.lib import get_ayon_launcher_args, run_detached_process
|
||||
|
||||
from ayon_core.pipeline.actions import (
|
||||
LoaderActionPlugin,
|
||||
LoaderActionItem,
|
||||
LoaderActionSelection,
|
||||
LoaderActionResult,
|
||||
)
|
||||
|
||||
|
||||
class PushToProject(LoaderActionPlugin):
|
||||
def get_action_items(
|
||||
self, selection: LoaderActionSelection
|
||||
) -> list[LoaderActionItem]:
|
||||
version_ids = set()
|
||||
if selection.selected_type == "version":
|
||||
version_ids = set(selection.selected_ids)
|
||||
|
||||
output = []
|
||||
if len(version_ids) == 1:
|
||||
output.append(
|
||||
LoaderActionItem(
|
||||
identifier="core.push-to-project",
|
||||
label="Push to project",
|
||||
order=35,
|
||||
entity_ids=version_ids,
|
||||
entity_type="version",
|
||||
icon={
|
||||
"type": "material-symbols",
|
||||
"name": "send",
|
||||
"color": "#d8d8d8",
|
||||
}
|
||||
)
|
||||
)
|
||||
return output
|
||||
|
||||
def execute_action(
|
||||
self,
|
||||
identifier: str,
|
||||
entity_ids: set[str],
|
||||
entity_type: str,
|
||||
selection: LoaderActionSelection,
|
||||
form_values: dict[str, Any],
|
||||
) -> Optional[LoaderActionResult]:
|
||||
if len(entity_ids) > 1:
|
||||
return LoaderActionResult(
|
||||
message="Please select only one version",
|
||||
success=False,
|
||||
)
|
||||
|
||||
push_tool_script_path = os.path.join(
|
||||
AYON_CORE_ROOT,
|
||||
"tools",
|
||||
"push_to_project",
|
||||
"main.py"
|
||||
)
|
||||
|
||||
version_id = next(iter(entity_ids))
|
||||
|
||||
args = get_ayon_launcher_args(
|
||||
push_tool_script_path,
|
||||
"--project", selection.project_name,
|
||||
"--version", version_id
|
||||
)
|
||||
run_detached_process(args)
|
||||
return LoaderActionResult(
|
||||
message="Push to project tool opened...",
|
||||
success=True,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue