removed obsolete methods for getting presets

This commit is contained in:
iLLiCiT 2019-07-31 00:47:40 +02:00
parent af78f6c606
commit 187bd09fa1
6 changed files with 43 additions and 81 deletions

View file

@ -1,6 +1,7 @@
import os
import re
import json
from pypeapp import config
from pype import lib as pypelib
from pype.lib import get_avalon_database
from bson.objectid import ObjectId
@ -53,8 +54,8 @@ def import_to_avalon(
if entity_type in ['Project']:
type = 'project'
config = get_project_config(entity)
schema.validate(config)
proj_config = get_project_config(entity)
schema.validate(proj_config)
av_project_code = None
if av_project is not None and 'code' in av_project['data']:
@ -68,7 +69,7 @@ def import_to_avalon(
'type': type,
'name': project_name,
'data': dict(),
'config': config,
'config': proj_config,
'parent': None,
}
schema.validate(item)
@ -345,13 +346,12 @@ def changeability_check_childs(entity):
childs = entity['children']
for child in childs:
if child.entity_type.lower() == 'task':
config = get_config_data()
if 'sync_to_avalon' in config:
config = config['sync_to_avalon']
if 'statuses_name_change' in config:
available_statuses = config['statuses_name_change']
else:
available_statuses = []
available_statuses = config.get_presets().get(
"ftrack", {}).get(
"ftrack_config", {}).get(
"sync_to_avalon", {}).get(
"statuses_name_change", []
)
ent_status = child['status']['name'].lower()
if ent_status not in available_statuses:
return False
@ -481,13 +481,13 @@ def get_avalon_project(ft_project):
def get_project_config(entity):
config = {}
config['schema'] = pypelib.get_avalon_project_config_schema()
config['tasks'] = get_tasks(entity)
config['apps'] = get_project_apps(entity)
config['template'] = pypelib.get_avalon_project_template()
proj_config = {}
proj_config['schema'] = pypelib.get_avalon_project_config_schema()
proj_config['tasks'] = get_tasks(entity)
proj_config['apps'] = get_project_apps(entity)
proj_config['template'] = pypelib.get_avalon_project_template()
return config
return proj_config
def get_tasks(project):
@ -557,24 +557,6 @@ def avalon_check_name(entity, inSchema=None):
raise ValueError(msg.format(name))
def get_config_data():
path_items = [pypelib.get_presets_path(), 'ftrack', 'ftrack_config.json']
filepath = os.path.sep.join(path_items)
data = dict()
try:
with open(filepath) as data_file:
data = json.load(data_file)
except Exception as e:
msg = (
'Loading "Ftrack Config file" Failed.'
' Please check log for more information.'
)
log.warning("{} - {}".format(msg, str(e)))
return data
def show_errors(obj, event, errors):
title = 'Hey You! You raised few Errors! (*look below*)'
items = []

View file

@ -5,7 +5,7 @@ from avalon import lib as avalonlib
import acre
from pype import api as pype
from pype import lib as pypelib
from .avalon_sync import get_config_data
from pypeapp import config
from .ftrack_base_handler import BaseHandler
from pypeapp import Anatomy
@ -328,10 +328,10 @@ class AppAction(BaseHandler):
pass
# Change status of task to In progress
config = get_config_data()
presets = config.get_presets()["ftrack"]["ftrack_config"]
if 'status_update' in config:
statuses = config['status_update']
if 'status_update' in presets:
statuses = presets['status_update']
actual_status = entity['status']['name'].lower()
next_status_name = None
@ -351,7 +351,7 @@ class AppAction(BaseHandler):
session.commit()
except Exception:
msg = (
'Status "{}" in config wasn\'t found on Ftrack'
'Status "{}" in presets wasn\'t found on Ftrack'
).format(next_status_name)
self.log.warning(msg)

View file

@ -473,13 +473,6 @@ def get_all_avalon_projects():
return projects
def get_presets_path():
templates = os.environ['PYPE_CONFIG']
path_items = [templates, 'presets']
filepath = os.path.sep.join(path_items)
return filepath
def filter_pyblish_plugins(plugins):
"""
This servers as plugin filter / modifier for pyblish. It will load plugin

View file

@ -1,22 +1,15 @@
import os
import subprocess
import json
from pype import lib as pypelib
from pypeapp import config
from avalon import api
def get_config_data():
path_items = [pypelib.get_presets_path(), 'djv_view', 'config.json']
filepath = os.path.sep.join(path_items)
data = dict()
with open(filepath) as data_file:
data = json.load(data_file)
return data
def get_families():
families = []
paths = get_config_data().get('djv_paths', [])
paths = config.get_presets().get("djv_view", {}).get("config", {}).get(
"djv_paths", []
)
for path in paths:
if os.path.exists(path):
families.append("*")
@ -25,13 +18,15 @@ def get_families():
def get_representation():
return get_config_data().get('file_ext', [])
return config.get_presets().get("djv_view", {}).get("config", {}).get(
'file_ext', []
)
class OpenInDJV(api.Loader):
"""Open Image Sequence with system default"""
config_data = get_config_data()
config_data = config.get_presets().get("djv_view", {}).get("config", {})
families = get_families()
representations = get_representation()
@ -42,7 +37,9 @@ class OpenInDJV(api.Loader):
def load(self, context, name, namespace, data):
self.djv_path = None
paths = get_config_data().get('djv_paths', [])
paths = config.get_presets().get("djv_view", {}).get("config", {}).get(
"djv_paths", []
)
for path in paths:
if os.path.exists(path):
self.djv_path = path

View file

@ -1,7 +1,7 @@
import os
import json
import pyblish.api
from pype import lib as pypelib
from pypeapp import config
class CollectOutputRepreConfig(pyblish.api.ContextPlugin):
@ -12,13 +12,5 @@ class CollectOutputRepreConfig(pyblish.api.ContextPlugin):
hosts = ["shell"]
def process(self, context):
config_items = [
pypelib.get_presets_path(),
"ftrack",
"output_representation.json"
]
config_file = os.path.sep.join(config_items)
with open(config_file) as data_file:
config_data = json.load(data_file)
config_data = config.get_presets()["ftrack"]["output_representation"]
context.data['output_repre_config'] = config_data

View file

@ -6,6 +6,7 @@ try:
import ftrack_api_old as ftrack_api
except Exception:
import ftrack_api
from pypeapp import config
from pype import lib as pypelib
from avalon.vendor.Qt import QtWidgets, QtCore
from avalon import io, api, style, schema
@ -194,18 +195,15 @@ class Window(QtWidgets.QDialog):
ft_project = session.query(project_query).one()
schema_name = ft_project['project_schema']['name']
# Load config
preset_path = pypelib.get_presets_path()
schemas_items = [preset_path, 'ftrack', 'project_schemas']
schema_dir = os.path.sep.join(schemas_items)
schemas_items = config.get_presets().get('ftrack', {}).get(
'project_schemas', {}
)
config_file = 'default.json'
for filename in os.listdir(schema_dir):
if filename.startswith(schema_name):
config_file = filename
break
config_file = os.path.sep.join([schema_dir, config_file])
with open(config_file) as data_file:
self.config_data = json.load(data_file)
key = "default"
if schema_name in schemas_items:
key = schema_name
self.config_data = schemas_items[key]
# set outlink
input_outlink = self.data['inputs']['outlink']