convert anatomy in plugins to new

This commit is contained in:
Milan Kolar 2019-04-13 01:06:48 +02:00
parent 44b9e48a67
commit dce33a9370
7 changed files with 27 additions and 22 deletions

View file

@ -63,4 +63,4 @@ def register(session):
time.sleep(0.1) time.sleep(0.1)
app_counter += 1 app_counter += 1
except Exception as e: except Exception as e:
log.warning("'{0}' - not proper App ({1})".format(app['name'], e)) log.exception("'{0}' - not proper App ({1})".format(app['name'], e))

View file

@ -227,10 +227,10 @@ class AppAction(BaseHandler):
except Exception: except Exception:
try: try:
anatomy = anatomy.format(data) anatomy = anatomy.format(data)
work_template = anatomy["work"]["path"] work_template = anatomy["work"]["folder"]
except Exception as e: except Exception as e:
self.log.error( self.log.exception(
"{0} Error in anatomy.format: {1}".format(__name__, e) "{0} Error in anatomy.format: {1}".format(__name__, e)
) )
os.environ["AVALON_WORKDIR"] = os.path.normpath(work_template) os.environ["AVALON_WORKDIR"] = os.path.normpath(work_template)
@ -296,7 +296,7 @@ class AppAction(BaseHandler):
try: try:
fp = open(execfile) fp = open(execfile)
except PermissionError as p: except PermissionError as p:
self.log.error('Access denied on {0} - {1}'.format( self.log.exception('Access denied on {0} - {1}'.format(
execfile, p)) execfile, p))
return { return {
'success': False, 'success': False,

View file

@ -81,7 +81,7 @@ class BaseHandler(object):
self.type, label) self.type, label)
) )
except Exception as e: except Exception as e:
self.log.error('{} "{}" - Registration failed ({})'.format( self.log.exception('{} "{}" - Registration failed ({})'.format(
self.type, label, str(e)) self.type, label, str(e))
) )
return wrapper_register return wrapper_register
@ -104,7 +104,7 @@ class BaseHandler(object):
return result return result
except Exception as e: except Exception as e:
msg = '{} "{}": Failed ({})'.format(self.type, label, str(e)) msg = '{} "{}": Failed ({})'.format(self.type, label, str(e))
self.log.error(msg) self.log.exception(msg)
return { return {
'success': False, 'success': False,
'message': msg 'message': msg

View file

@ -23,7 +23,7 @@ class CollectAssumedDestination(pyblish.api.InstancePlugin):
anatomy = instance.context.data['anatomy'] anatomy = instance.context.data['anatomy']
# self.log.info(anatomy.anatomy()) # self.log.info(anatomy.anatomy())
self.log.info(anatomy.anatomy) self.log.info(anatomy.templates)
# template = anatomy.publish.path # template = anatomy.publish.path
anatomy_filled = anatomy.format(template_data) anatomy_filled = anatomy.format(template_data)
self.log.info(anatomy_filled) self.log.info(anatomy_filled)
@ -137,5 +137,5 @@ class CollectAssumedDestination(pyblish.api.InstancePlugin):
# We take the parent folder of representation 'filepath' # We take the parent folder of representation 'filepath'
instance.data["assumedDestination"] = os.path.dirname( instance.data["assumedDestination"] = os.path.dirname(
(anatomy.format(template_data)).publish.path (anatomy.format(template_data))["publish"]["path"]
) )

View file

@ -1,5 +1,6 @@
import pype.api as pype import pype.api as pype
from pypeapp import Anatomy
import pyblish.api import pyblish.api
@ -11,6 +12,6 @@ class CollectTemplates(pyblish.api.ContextPlugin):
label = "Collect Templates" label = "Collect Templates"
def process(self, context): def process(self, context):
pype.load_data_from_templates() # pype.load_data_from_templates()
context.data['anatomy'] = pype.Anatomy context.data['anatomy'] = Anatomy()
self.log.info("Anatomy templates collected...") self.log.info("Anatomy templates collected...")

View file

@ -210,10 +210,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
src = os.path.join(stagingdir, fname) src = os.path.join(stagingdir, fname)
anatomy_filled = anatomy.format(template_data) anatomy_filled = anatomy.format(template_data)
dst = anatomy_filled.publish.path dst = anatomy_filled["publish"]["path"]
instance.data["transfers"].append([src, dst]) instance.data["transfers"].append([src, dst])
template = anatomy.publish.path template = anatomy.templates["publish"]["path"]
else: else:
# Single file # Single file
@ -234,10 +234,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
src = os.path.join(stagingdir, fname) src = os.path.join(stagingdir, fname)
anatomy_filled = anatomy.format(template_data) anatomy_filled = anatomy.format(template_data)
dst = anatomy_filled.publish.path dst = anatomy_filled["publish"]["path"]
instance.data["transfers"].append([src, dst]) instance.data["transfers"].append([src, dst])
template = anatomy.publish.path template = anatomy.templates["publish"]["path"]
representation = { representation = {
"schema": "pype:representation-2.0", "schema": "pype:representation-2.0",

View file

@ -1,4 +1,5 @@
import pyblish.api import pyblish.api
import os
class ValidateTemplates(pyblish.api.ContextPlugin): class ValidateTemplates(pyblish.api.ContextPlugin):
"""Check if all templates were filed""" """Check if all templates were filed"""
@ -13,25 +14,28 @@ class ValidateTemplates(pyblish.api.ContextPlugin):
if not anatomy: if not anatomy:
raise RuntimeError("Did not find anatomy") raise RuntimeError("Did not find anatomy")
else: else:
data = { "project": {"name": "D001_projectsx", data = {
"root": os.environ["PYPE_STUDIO_PROJECTS_PATH"],
"project": {"name": "D001_projectsx",
"code": "prjX"}, "code": "prjX"},
"representation": "exr", "ext": "exr",
"version": 3, "version": 3,
"task": "animation", "task": "animation",
"asset": "sh001", "asset": "sh001",
"hierarchy": "ep101/sq01/sh010"} "hierarchy": "ep101/sq01/sh010"}
anatomy = context.data["anatomy"].format(data) anatomy_filled = anatomy.format(data)
self.log.info(anatomy["work"]["path"]) self.log.info(anatomy_filled)
data = { "project": {"name": "D001_projectsy", data = {"root": os.environ["PYPE_STUDIO_PROJECTS_PATH"],
"project": {"name": "D001_projectsy",
"code": "prjY"}, "code": "prjY"},
"representation": "abc", "ext": "abc",
"version": 1, "version": 1,
"task": "lookdev", "task": "lookdev",
"asset": "bob", "asset": "bob",
"hierarchy": "ep101/sq01/bob"} "hierarchy": "ep101/sq01/bob"}
anatomy = context.data["anatomy"].format(data) anatomy_filled = context.data["anatomy"].format(data)
self.log.info(anatomy["work"]["file"]) self.log.info(anatomy_filled["work"]["folder"])