mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
(maya) adding changes to update previous commit
This commit is contained in:
parent
e951cd36b0
commit
66b8a18a66
2 changed files with 111 additions and 9 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import pyblish.api
|
||||
import os
|
||||
import logging
|
||||
|
||||
import pyblish.api
|
||||
from avalon import api, io
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -53,5 +55,109 @@ class UpdateVersion(pyblish.api.InstancePlugin):
|
|||
"parent": asset["_id"],
|
||||
"name": subset_to_attach["subset"]})
|
||||
|
||||
assert all([project, asset]), ("Could not find current project or "
|
||||
"asset '%s'" % ASSET)
|
||||
assert all([project, asset]), ("Could not find current project or "
|
||||
"asset '%s'" % ASSET)
|
||||
|
||||
attach_version = subset_to_attach["version"]
|
||||
|
||||
version_data = self.create_version_data(context, instance)
|
||||
|
||||
version_data_instance = instance.data.get('versionData')
|
||||
|
||||
if version_data_instance:
|
||||
version_data.update(version_data_instance)
|
||||
|
||||
version = self.create_version(subset=subset,
|
||||
version_number=attach_version,
|
||||
locations=[LOCATION],
|
||||
data=version_data)
|
||||
|
||||
self.log.debug("Creating version ...")
|
||||
existing_version = io.find_one({
|
||||
'type': 'version',
|
||||
'parent': subset["_id"],
|
||||
'name': attach_version
|
||||
})
|
||||
if existing_version is None:
|
||||
version_id = io.insert_one(version).inserted_id
|
||||
else:
|
||||
io.update_many({
|
||||
'type': 'version',
|
||||
'parent': subset["_id"],
|
||||
'name': attach_version
|
||||
}, {'$set': version}
|
||||
)
|
||||
version_id = existing_version['_id']
|
||||
instance.data['version'] = version['name']
|
||||
|
||||
def create_version(self, subset, version_number, locations, data=None):
|
||||
""" Copy given source to destination
|
||||
|
||||
Args:
|
||||
subset (dict): the registered subset of the asset
|
||||
version_number (int): the version number
|
||||
locations (list): the currently registered locations
|
||||
|
||||
Returns:
|
||||
dict: collection of data to create a version
|
||||
"""
|
||||
# Imprint currently registered location
|
||||
version_locations = [location for location in locations if
|
||||
location is not None]
|
||||
|
||||
return {"schema": "pype:version-3.0",
|
||||
"type": "version",
|
||||
"parent": subset["_id"],
|
||||
"name": version_number,
|
||||
"locations": version_locations,
|
||||
"data": data}
|
||||
|
||||
def create_version_data(self, context, instance):
|
||||
"""Create the data collection for the version
|
||||
|
||||
Args:
|
||||
context: the current context
|
||||
instance: the current instance being published
|
||||
|
||||
Returns:
|
||||
dict: the required information with instance.data as key
|
||||
"""
|
||||
|
||||
families = []
|
||||
current_families = instance.data.get("families", list())
|
||||
instance_family = instance.data.get("family", None)
|
||||
|
||||
if instance_family is not None:
|
||||
families.append(instance_family)
|
||||
families += current_families
|
||||
|
||||
self.log.debug("Registered root: {}".format(api.registered_root()))
|
||||
# create relative source path for DB
|
||||
try:
|
||||
source = instance.data['source']
|
||||
except KeyError:
|
||||
source = context.data["currentFile"]
|
||||
source = source.replace(os.getenv("PYPE_STUDIO_PROJECTS_MOUNT"),
|
||||
api.registered_root())
|
||||
relative_path = os.path.relpath(source, api.registered_root())
|
||||
source = os.path.join("{root}", relative_path).replace("\\", "/")
|
||||
|
||||
self.log.debug("Source: {}".format(source))
|
||||
version_data = {"families": families,
|
||||
"time": context.data["time"],
|
||||
"author": context.data["user"],
|
||||
"source": source,
|
||||
"comment": context.data.get("comment"),
|
||||
"machine": context.data.get("machine"),
|
||||
"fps": context.data.get("fps")}
|
||||
|
||||
# Include optional data if present in
|
||||
optionals = [
|
||||
"frameStart", "frameEnd", "step", "handles",
|
||||
"handleEnd", "handleStart", "sourceHashes"
|
||||
]
|
||||
for key in optionals:
|
||||
if key in instance.data:
|
||||
version_data[key] = instance.data[key]
|
||||
|
||||
return version_data
|
||||
|
|
|
|||
|
|
@ -69,12 +69,10 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
|
|||
sets = cmds.sets(layer, query=True) or []
|
||||
if sets:
|
||||
for s in sets:
|
||||
self.log.info(" - attach render to: {}".format(s))
|
||||
|
||||
self.log.debug("marked subsets: {}".format(sets))
|
||||
self.log.info(" -> attach render to: {}".format(s))
|
||||
|
||||
layer_name = "rs_{}".format(expected_layer_name)
|
||||
self.log.info(" - %s" % layer_name)
|
||||
|
||||
# Get layer specific settings, might be overrides
|
||||
data = {
|
||||
"subset": expected_layer_name,
|
||||
|
|
@ -147,8 +145,6 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
|
|||
|
||||
attributes = maya.read(render_globals)
|
||||
|
||||
self.log.info(attributes)
|
||||
|
||||
options = {"renderGlobals": {}}
|
||||
options["renderGlobals"]["Priority"] = attributes["priority"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue