mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
Sync to avalon exports all Custom Attributes in 'avalon' group without 'avalon_' in key
This commit is contained in:
parent
d724eba9f9
commit
47e36bb432
4 changed files with 68 additions and 39 deletions
|
|
@ -6,6 +6,7 @@ import logging
|
|||
import os
|
||||
import ftrack_api
|
||||
import json
|
||||
import re
|
||||
from ftrack_action_handler import BaseAction
|
||||
|
||||
from avalon import io, inventory, lib
|
||||
|
|
@ -54,6 +55,7 @@ class SyncToAvalon(BaseAction):
|
|||
print("action <" + self.__class__.__name__ + "> is running")
|
||||
|
||||
#TODO AVALON_PROJECTS, AVALON_ASSET, AVALON_SILO should be set up otherwise console log shows avalon debug
|
||||
self.setAvalonAttributes(session)
|
||||
self.importable = []
|
||||
|
||||
# get from top entity in hierarchy all parent entities
|
||||
|
|
@ -105,6 +107,12 @@ class SyncToAvalon(BaseAction):
|
|||
'success': True,
|
||||
'message': "Synchronization was successfull"
|
||||
}
|
||||
def setAvalonAttributes(self, session):
|
||||
self.custom_attributes = []
|
||||
all_avalon_attr = session.query('CustomAttributeGroup where name is "avalon"').one()
|
||||
for cust_attr in all_avalon_attr['custom_attribute_configurations']:
|
||||
if 'avalon_' not in cust_attr['key']:
|
||||
self.custom_attributes.append(cust_attr)
|
||||
|
||||
def getShotAsset(self, entity):
|
||||
if not (entity.entity_type in ['Task']):
|
||||
|
|
@ -150,7 +158,6 @@ class SyncToAvalon(BaseAction):
|
|||
eLinks = []
|
||||
|
||||
ca_mongoid = 'avalon_mongo_id'
|
||||
ca_tools = 'avalon_tools_env'
|
||||
|
||||
# get needed info of entity and all parents
|
||||
for e in entity['link']:
|
||||
|
|
@ -171,8 +178,28 @@ class SyncToAvalon(BaseAction):
|
|||
## ----- PROJECT ------
|
||||
# If project don't exists -> <Create project> ELSE <Update Config>
|
||||
avalon_project = io.find_one({"type": "project", "name": entityProj["full_name"]})
|
||||
entity_type = entity.entity_type
|
||||
|
||||
data = {}
|
||||
data['ftrackId'] = entity['id']
|
||||
data['entityType'] = entity_type
|
||||
|
||||
for cust_attr in self.custom_attributes:
|
||||
if cust_attr['entity_type'].lower() in ['asset']:
|
||||
data[cust_attr['key']] = entity['custom_attributes'][cust_attr['key']]
|
||||
|
||||
elif cust_attr['entity_type'].lower() in ['show'] and entity_type.lower() == 'project':
|
||||
data[cust_attr['key']] = entity['custom_attributes'][cust_attr['key']]
|
||||
|
||||
elif cust_attr['entity_type'].lower() in ['task'] and entity_type.lower() != 'project':
|
||||
# Put space between capitals (e.g. 'AssetBuild' -> 'Asset Build')
|
||||
entity_type = re.sub(r"(\w)([A-Z])", r"\1 \2", entity_type)
|
||||
# Get object id of entity type
|
||||
ent_obj_type_id = session.query('ObjectType where name is "{}"'.format(entity_type)).one()['id']
|
||||
|
||||
if cust_attr['object_type_id'] == ent_obj_type_id:
|
||||
data[cust_attr['key']] = entity['custom_attributes'][cust_attr['key']]
|
||||
|
||||
tools = entity['custom_attributes'][ca_tools]
|
||||
|
||||
if entity.entity_type.lower() in ['project']:
|
||||
# Set project Config
|
||||
|
|
@ -184,17 +211,13 @@ class SyncToAvalon(BaseAction):
|
|||
io.update_many({'type': 'project','name': entityProj['full_name']},
|
||||
{'$set':{'config':config}})
|
||||
|
||||
data['code'] = entity['name']
|
||||
|
||||
# Store info about project (FtrackId)
|
||||
io.update_many({
|
||||
'type': 'project',
|
||||
'name': entity['full_name']
|
||||
}, {
|
||||
'$set':{'data':{
|
||||
'code':entity['name'],
|
||||
'ftrackId':entity['id'],
|
||||
'entityType':entity.entity_type,
|
||||
'tools':tools
|
||||
}}})
|
||||
'name': entity['full_name']},
|
||||
{'$set':{'data':data}})
|
||||
|
||||
projectId = io.find_one({"type": "project", "name": entityProj["full_name"]})["_id"]
|
||||
if ca_mongoid in entity['custom_attributes']:
|
||||
|
|
@ -206,7 +229,7 @@ class SyncToAvalon(BaseAction):
|
|||
|
||||
# Store project Id
|
||||
projectId = avalon_project["_id"]
|
||||
|
||||
|
||||
## ----- ASSETS ------
|
||||
# Presets:
|
||||
# TODO how to check if entity is Asset Library or AssetBuild?
|
||||
|
|
@ -241,15 +264,11 @@ class SyncToAvalon(BaseAction):
|
|||
|
||||
hierarchy = os.path.sep.join(folderStruct)
|
||||
|
||||
data = {
|
||||
'visualParent': parentId,
|
||||
'parents': folderStruct,
|
||||
'tasks': tasks,
|
||||
'hierarchy': hierarchy,
|
||||
'tools': tools,
|
||||
'ftrackId': entity['id'],
|
||||
'entityType': entity.entity_type
|
||||
}
|
||||
data['visualParent'] = parentId
|
||||
data['parents'] = folderStruct
|
||||
data['tasks'] = tasks
|
||||
data['hierarchy'] = hierarchy
|
||||
|
||||
|
||||
name = self.checkName(entity['name'])
|
||||
os.environ['AVALON_ASSET'] = name
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import logging
|
|||
import collections
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
|
||||
import ftrack_api
|
||||
from ftrack_action_handler import BaseAction
|
||||
|
|
@ -31,24 +32,33 @@ class TestAction(BaseAction):
|
|||
|
||||
|
||||
def launch(self, session, entities, event):
|
||||
|
||||
for entity in entities:
|
||||
index = 0
|
||||
name = entity['components'][index]['name']
|
||||
filetype = entity['components'][index]['file_type']
|
||||
path = entity['components'][index]['component_locations'][0]['resource_identifier']
|
||||
|
||||
# entity['components'][index]['component_locations'][0]['resource_identifier'] = r"C:\Users\jakub.trllo\Desktop\test\exr\int_c022_lighting_v001_main_AO.%04d.exr"
|
||||
location = entity['components'][0]['component_locations'][0]['location']
|
||||
component = entity['components'][0]
|
||||
entity = entities[0]
|
||||
|
||||
|
||||
# print(location.get_filesystem_path(component))
|
||||
entity_type = entity.entity_type
|
||||
data = {}
|
||||
"""
|
||||
custom_attributes = []
|
||||
|
||||
# for k in p:
|
||||
# print(100*"-")
|
||||
# print(k)
|
||||
# print(p[k])
|
||||
all_avalon_attr = session.query('CustomAttributeGroup where name is "avalon"').one()
|
||||
for cust_attr in all_avalon_attr['custom_attribute_configurations']:
|
||||
if 'avalon_' not in cust_attr['key']:
|
||||
custom_attributes.append(cust_attr)
|
||||
"""
|
||||
for cust_attr in custom_attributes:
|
||||
if cust_attr['entity_type'].lower() in ['asset']:
|
||||
data[cust_attr['key']] = entity['custom_attributes'][cust_attr['key']]
|
||||
|
||||
elif cust_attr['entity_type'].lower() in ['show'] and entity_type.lower() == 'project':
|
||||
data[cust_attr['key']] = entity['custom_attributes'][cust_attr['key']]
|
||||
|
||||
elif cust_attr['entity_type'].lower() in ['task'] and entity_type.lower() != 'project':
|
||||
# Put space between capitals (e.g. 'AssetBuild' -> 'Asset Build')
|
||||
entity_type = re.sub(r"(\w)([A-Z])", r"\1 \2", entity_type)
|
||||
# Get object id of entity type
|
||||
ent_obj_type_id = session.query('ObjectType where name is "{}"'.format(entity_type)).one()['id']
|
||||
if cust_attr['type_id'] == ent_obj_type_id:
|
||||
data[cust_attr['key']] = entity['custom_attributes'][cust_attr['key']]
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import sys
|
||||
import os
|
||||
import requests
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
from app.vendor.Qt import QtCore, QtGui, QtWidgets
|
||||
from app import style
|
||||
from . import credentials, login_tools
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ class Login_Dialog_ui(QtWidgets.QWidget):
|
|||
SIZE_W = 300
|
||||
SIZE_H = 230
|
||||
|
||||
loginSignal = QtCore.pyqtSignal(object, object, object)
|
||||
loginSignal = QtCore.Signal(object, object, object)
|
||||
_login_server_thread = None
|
||||
inputs = []
|
||||
buttons = []
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
|
|||
from urllib import parse
|
||||
import webbrowser
|
||||
import functools
|
||||
from PyQt5 import QtCore
|
||||
from app.vendor.Qt import QtCore
|
||||
|
||||
# class LoginServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
class LoginServerHandler(BaseHTTPRequestHandler):
|
||||
|
|
@ -82,7 +82,7 @@ class LoginServerThread(QtCore.QThread):
|
|||
'''Login server thread.'''
|
||||
|
||||
# Login signal.
|
||||
loginSignal = QtCore.pyqtSignal(object, object, object)
|
||||
loginSignal = QtCore.Signal(object, object, object)
|
||||
|
||||
|
||||
def start(self, url):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue