mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added push to library loader
This commit is contained in:
parent
74984afc7b
commit
23d2f78a38
1 changed files with 52 additions and 0 deletions
52
openpype/plugins/load/push_to_library.py
Normal file
52
openpype/plugins/load/push_to_library.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import os
|
||||
|
||||
from openpype import PACKAGE_DIR
|
||||
from openpype.lib import get_openpype_execute_args, run_detached_process
|
||||
from openpype.pipeline import load
|
||||
from openpype.pipeline.load import LoadError
|
||||
|
||||
|
||||
class PushToLibraryProject(load.SubsetLoaderPlugin):
|
||||
"""Export selected versions to folder structure from Template"""
|
||||
|
||||
is_multiple_contexts_compatible = True
|
||||
|
||||
representations = ["*"]
|
||||
families = ["*"]
|
||||
|
||||
label = "Push to Library 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(
|
||||
PACKAGE_DIR,
|
||||
"tools",
|
||||
"push_to_project",
|
||||
"app.py"
|
||||
)
|
||||
project_doc = context["project"]
|
||||
version_doc = context["version"]
|
||||
project_name = project_doc["name"]
|
||||
version_id = str(version_doc["_id"])
|
||||
|
||||
args = get_openpype_execute_args(
|
||||
"run",
|
||||
push_tool_script_path,
|
||||
"--project", project_name,
|
||||
"--version", version_id
|
||||
)
|
||||
run_detached_process(args)
|
||||
Loading…
Add table
Add a link
Reference in a new issue