mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
fix environment loading
This commit is contained in:
parent
636ded0fc5
commit
e281bf6afa
3 changed files with 29 additions and 9 deletions
|
|
@ -1,14 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""Tools used in **Igniter** GUI."""
|
"""Tools used in **Igniter** GUI."""
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
from pype.lib import decompose_url, compose_url
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
from pymongo.errors import ServerSelectionTimeoutError, InvalidURI
|
from pymongo.errors import ServerSelectionTimeoutError, InvalidURI
|
||||||
|
|
||||||
|
from pype.lib import decompose_url, compose_url
|
||||||
|
|
||||||
|
|
||||||
def validate_mongo_connection(cnx: str) -> (bool, str):
|
def validate_mongo_connection(cnx: str) -> (bool, str):
|
||||||
"""Check if provided mongodb URL is valid.
|
"""Check if provided mongodb URL is valid.
|
||||||
|
|
@ -80,12 +81,15 @@ def validate_path_string(path: str) -> (bool, str):
|
||||||
return False, "Not implemented yet"
|
return False, "Not implemented yet"
|
||||||
|
|
||||||
|
|
||||||
def load_environments() -> dict:
|
def load_environments(sections: list = None) -> dict:
|
||||||
"""Load environments from Pype.
|
"""Load environments from Pype.
|
||||||
|
|
||||||
This will load environments from database, process them with
|
This will load environments from database, process them with
|
||||||
:mod:`acre` and return them as flattened dictionary.
|
:mod:`acre` and return them as flattened dictionary.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
sections (list, optional): load specific types
|
||||||
|
|
||||||
Returns;
|
Returns;
|
||||||
dict of str: loaded and processed environments.
|
dict of str: loaded and processed environments.
|
||||||
|
|
||||||
|
|
@ -99,10 +103,15 @@ def load_environments() -> dict:
|
||||||
|
|
||||||
all_env = settings.environments()
|
all_env = settings.environments()
|
||||||
merged_env = {}
|
merged_env = {}
|
||||||
for _, v in all_env.items():
|
|
||||||
if isinstance(v, dict):
|
sections = sections or all_env.keys()
|
||||||
parsed_env = acre.parse(v)
|
|
||||||
merged_env = acre.append(merged_env, parsed_env)
|
for section in sections:
|
||||||
|
try:
|
||||||
|
parsed_env = acre.parse(all_env[section])
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
|
merged_env = acre.append(merged_env, parsed_env)
|
||||||
|
|
||||||
env = acre.compute(merged_env, cleanup=True)
|
env = acre.compute(merged_env, cleanup=True)
|
||||||
return env
|
return env
|
||||||
|
|
|
||||||
12
pype.py
12
pype.py
|
|
@ -36,10 +36,11 @@ settings or via **Igniter** GUI.
|
||||||
https://www.mongodb.com/
|
https://www.mongodb.com/
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from igniter.tools import load_environments
|
from igniter.tools import load_environments
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -51,7 +52,14 @@ from igniter import BootstrapRepos
|
||||||
|
|
||||||
|
|
||||||
def set_environments() -> None:
|
def set_environments() -> None:
|
||||||
env = load_environments()
|
"""Set loaded environments.
|
||||||
|
|
||||||
|
.. todo:
|
||||||
|
better handling of environments
|
||||||
|
|
||||||
|
"""
|
||||||
|
# FIXME: remove everything except global
|
||||||
|
env = load_environments(["global", "avalon", "ftrack"])
|
||||||
env = acre.merge(env, dict(os.environ))
|
env = acre.merge(env, dict(os.environ))
|
||||||
os.environ.clear()
|
os.environ.clear()
|
||||||
os.environ.update(env)
|
os.environ.update(env)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
s = dict(os.environ)
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
from avalon import style
|
from avalon import style
|
||||||
from Qt import QtCore, QtGui, QtWidgets, QtSvg
|
from Qt import QtCore, QtGui, QtWidgets, QtSvg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue