mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Top entity is not pushed to Avalon as asset and error message is full now
This commit is contained in:
parent
9910fa0b0d
commit
6e0fc1771d
2 changed files with 16 additions and 18 deletions
|
|
@ -233,10 +233,12 @@ class SyncToAvalon(BaseAction):
|
|||
|
||||
## ----- ASSETS ------
|
||||
# Presets:
|
||||
|
||||
data = ftrack_utils.get_data(self, entity, session, self.custom_attributes)
|
||||
silo = entity['name']
|
||||
if len(data['parents']) > 0:
|
||||
|
||||
# return if entity is silo
|
||||
if len(data['parents']) == 0:
|
||||
return
|
||||
else:
|
||||
silo = data['parents'][0]
|
||||
|
||||
os.environ['AVALON_SILO'] = silo
|
||||
|
|
@ -263,16 +265,11 @@ class SyncToAvalon(BaseAction):
|
|||
|
||||
# Raise error if it seems to be different ent. with same name
|
||||
else:
|
||||
update = False
|
||||
aD = avalon_asset['data']
|
||||
check_attr = ['ftrackId', 'visualParent', 'parents']
|
||||
for attr in check_attr:
|
||||
if attr not in aD: update = True
|
||||
|
||||
if update is False:
|
||||
for attr in check_attr:
|
||||
if (avalon_asset['data'][attr] != data[attr]):
|
||||
raise ValueError('In Avalon DB already exists entity with name <{}>!'.format(name))
|
||||
# check_attr = ['parents', 'ftrackId', 'visualParent']
|
||||
if (avalon_asset['data']['parents'] != data['parents'] or
|
||||
avalon_asset['silo'] != silo):
|
||||
raise ValueError('In Avalon DB already exists entity with name "{0}"'.format(name))
|
||||
|
||||
elif avalon_asset['name'] != entity['name']:
|
||||
raise ValueError('You can\'t change name {} to {}, avalon DB won\'t work properly - please create new asset'.format(avalon_asset['name'], name))
|
||||
|
|
|
|||
|
|
@ -49,16 +49,17 @@ def get_data(parent, entity, session, custom_attributes):
|
|||
|
||||
# Get list of parents without project
|
||||
parents = []
|
||||
for i in range(1, len(entity['link'])-1):
|
||||
tmp = session.get(entity['link'][i]['type'], entity['link'][i]['id'])
|
||||
parents.append(tmp)
|
||||
|
||||
folderStruct = []
|
||||
for i in range(1, len(entity['link'])-1):
|
||||
parEnt = session.get(entity['link'][i]['type'], entity['link'][i]['id'])
|
||||
parName = parEnt['name']
|
||||
folderStruct.append(parName)
|
||||
if i > 1:
|
||||
parents.append(parEnt)
|
||||
|
||||
parentId = None
|
||||
|
||||
for parent in parents:
|
||||
parName = parent['name']
|
||||
folderStruct.append(parName)
|
||||
parentId = io.find_one({'type': 'asset', 'name': parName})['_id']
|
||||
if parent['parent'].entity_type != 'project' and parentId is None:
|
||||
parent.importToAvalon(parent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue