mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +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 -*-
|
||||
"""Tools used in **Igniter** GUI."""
|
||||
import sys
|
||||
import os
|
||||
import sys
|
||||
import uuid
|
||||
from pype.lib import decompose_url, compose_url
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pymongo import MongoClient
|
||||
from pymongo.errors import ServerSelectionTimeoutError, InvalidURI
|
||||
|
||||
from pype.lib import decompose_url, compose_url
|
||||
|
||||
|
||||
def validate_mongo_connection(cnx: str) -> (bool, str):
|
||||
"""Check if provided mongodb URL is valid.
|
||||
|
|
@ -80,12 +81,15 @@ def validate_path_string(path: str) -> (bool, str):
|
|||
return False, "Not implemented yet"
|
||||
|
||||
|
||||
def load_environments() -> dict:
|
||||
def load_environments(sections: list = None) -> dict:
|
||||
"""Load environments from Pype.
|
||||
|
||||
This will load environments from database, process them with
|
||||
:mod:`acre` and return them as flattened dictionary.
|
||||
|
||||
Args:
|
||||
sections (list, optional): load specific types
|
||||
|
||||
Returns;
|
||||
dict of str: loaded and processed environments.
|
||||
|
||||
|
|
@ -99,10 +103,15 @@ def load_environments() -> dict:
|
|||
|
||||
all_env = settings.environments()
|
||||
merged_env = {}
|
||||
for _, v in all_env.items():
|
||||
if isinstance(v, dict):
|
||||
parsed_env = acre.parse(v)
|
||||
merged_env = acre.append(merged_env, parsed_env)
|
||||
|
||||
sections = sections or all_env.keys()
|
||||
|
||||
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)
|
||||
return env
|
||||
|
|
|
|||
12
pype.py
12
pype.py
|
|
@ -36,10 +36,11 @@ settings or via **Igniter** GUI.
|
|||
https://www.mongodb.com/
|
||||
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from igniter.tools import load_environments
|
||||
|
||||
try:
|
||||
|
|
@ -51,7 +52,14 @@ from igniter import BootstrapRepos
|
|||
|
||||
|
||||
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))
|
||||
os.environ.clear()
|
||||
os.environ.update(env)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
s = dict(os.environ)
|
||||
|
||||
import platform
|
||||
from avalon import style
|
||||
from Qt import QtCore, QtGui, QtWidgets, QtSvg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue