mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Publish workfile
This commit is contained in:
parent
2e5a3922bc
commit
59d3ab14b2
4 changed files with 115 additions and 0 deletions
28
pype/plugins/harmony/publish/collect_workfile.py
Normal file
28
pype/plugins/harmony/publish/collect_workfile.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import pyblish.api
|
||||
import os
|
||||
|
||||
|
||||
class CollectWorkfile(pyblish.api.ContextPlugin):
|
||||
"""Collect current script for publish."""
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.1
|
||||
label = "Collect Workfile"
|
||||
hosts = ["harmony"]
|
||||
|
||||
def process(self, context):
|
||||
family = "workfile"
|
||||
task = os.getenv("AVALON_TASK", None)
|
||||
subset = family + task.capitalize()
|
||||
basename = os.path.basename(context.data["currentFile"])
|
||||
|
||||
# Create instance
|
||||
instance = context.create_instance(subset)
|
||||
instance.data.update({
|
||||
"subset": subset,
|
||||
"label": basename,
|
||||
"name": basename,
|
||||
"family": family,
|
||||
"families": [],
|
||||
"representations": [],
|
||||
"asset": os.environ["AVALON_ASSET"]
|
||||
})
|
||||
13
pype/plugins/harmony/publish/extract_save_scene.py
Normal file
13
pype/plugins/harmony/publish/extract_save_scene.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import pyblish.api
|
||||
from avalon import harmony
|
||||
|
||||
|
||||
class ExtractSaveScene(pyblish.api.ContextPlugin):
|
||||
"""Save scene for extraction."""
|
||||
|
||||
label = "Extract Save Scene"
|
||||
order = pyblish.api.ExtractorOrder - 0.49
|
||||
hosts = ["harmony"]
|
||||
|
||||
def process(self, instance):
|
||||
harmony.save_scene()
|
||||
34
pype/plugins/harmony/publish/extract_workfile.py
Normal file
34
pype/plugins/harmony/publish/extract_workfile.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
import pype.api
|
||||
from avalon import harmony
|
||||
|
||||
|
||||
class ExtractWorkfile(pype.api.Extractor):
|
||||
"""Extract the connected nodes to the composite instance."""
|
||||
|
||||
label = "Extract Workfile"
|
||||
hosts = ["harmony"]
|
||||
families = ["workfile"]
|
||||
|
||||
def process(self, instance):
|
||||
file_path = instance.context.data["currentFile"]
|
||||
staging_dir = self.staging_dir(instance)
|
||||
|
||||
os.chdir(staging_dir)
|
||||
shutil.make_archive(
|
||||
instance.name,
|
||||
"zip",
|
||||
os.path.dirname(file_path)
|
||||
)
|
||||
zip_path = os.path.join(staging_dir, instance.name + ".zip")
|
||||
self.log.info(f"Output zip file: {zip_path}")
|
||||
|
||||
representation = {
|
||||
"name": "tpl",
|
||||
"ext": "zip",
|
||||
"files": "{}.zip".format(instance.name),
|
||||
"stagingDir": staging_dir
|
||||
}
|
||||
instance.data["representations"] = [representation]
|
||||
40
pype/plugins/harmony/publish/increment_workfile.py
Normal file
40
pype/plugins/harmony/publish/increment_workfile.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
import pyblish.api
|
||||
from pype.action import get_errored_plugins_from_data
|
||||
from pype.lib import version_up
|
||||
import pype.api
|
||||
from avalon import harmony
|
||||
|
||||
|
||||
class IncrementWorkfile(pyblish.api.InstancePlugin):
|
||||
"""Increment the current workfile.
|
||||
|
||||
Saves the current scene with an increased version number.
|
||||
"""
|
||||
|
||||
label = "Increment Workfile"
|
||||
order = pyblish.api.IntegratorOrder + 9.0
|
||||
hosts = ["harmony"]
|
||||
families = ["workfile"]
|
||||
optional = True
|
||||
|
||||
def process(self, instance):
|
||||
errored_plugins = get_errored_plugins_from_data(instance.context)
|
||||
if errored_plugins:
|
||||
raise RuntimeError(
|
||||
"Skipping incrementing current file because submission to"
|
||||
" deadline failed."
|
||||
)
|
||||
|
||||
scene_dir = version_up(
|
||||
os.path.dirname(instance.context.data["currentFile"])
|
||||
)
|
||||
scene_path = os.path.join(
|
||||
scene_dir, os.path.basename(scene_dir) + ".xstage"
|
||||
)
|
||||
|
||||
harmony.save_scene_as(scene_path)
|
||||
|
||||
self.log.info("Incremented workfile to: {}".format(scene_path))
|
||||
Loading…
Add table
Add a link
Reference in a new issue