Merge pull request #1075 from pypeclub/bugfix/1069-fix-resolving-of-_schema_dir

Fix resolving of  schema dir
This commit is contained in:
Milan Kolar 2021-03-03 09:55:12 +01:00 committed by GitHub
commit a5cba994d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 46 deletions

View file

@ -201,8 +201,11 @@ class PypeLogger:
# Information about mongo url
log_mongo_url = None
log_mongo_url_components = None
log_database_name = None
log_collection_name = None
# Database name in Mongo
log_database_name = "pype"
# Collection name under database in Mongo
log_collection_name = "logs"
# PYPE_DEBUG
pype_debug = 0
@ -348,25 +351,14 @@ class PypeLogger:
cls.pype_debug = int(os.getenv("PYPE_DEBUG") or "0")
# Mongo URL where logs will be stored
cls.log_mongo_url = (
os.environ.get("PYPE_LOG_MONGO_URL")
or os.environ.get("PYPE_MONGO")
)
cls.log_mongo_url = os.environ.get("PYPE_MONGO")
if not cls.log_mongo_url:
cls.use_mongo_logging = False
else:
# Decompose url
cls.log_mongo_url_components = decompose_url(cls.log_mongo_url)
# Database name in Mongo
cls.log_database_name = (
os.environ.get("PYPE_LOG_MONGO_DB") or "pype"
)
# Collection name under database in Mongo
cls.log_collection_name = (
os.environ.get("PYPE_LOG_MONGO_COL") or "logs"
)
# Mark as initialized
cls.initialized = True

View file

@ -38,11 +38,6 @@ class AvalonModule(PypeModule, ITrayModule, IRestApi):
self.avalon_mongo_url = avalon_mongo_url
self.avalon_mongo_timeout = avalon_mongo_timeout
self.schema_path = os.path.join(
os.path.dirname(pype.PACKAGE_DIR),
"schema"
)
# Tray attributes
self.libraryloader = None
self.rest_api_obj = None
@ -50,23 +45,11 @@ class AvalonModule(PypeModule, ITrayModule, IRestApi):
def get_global_environments(self):
"""Avalon global environments for pype implementation."""
return {
# 100% hardcoded
"AVALON_SCHEMA": self.schema_path,
"AVALON_CONFIG": "pype",
"AVALON_LABEL": "Pype",
# Modifiable by settings
# - mongo ulr for avalon projects
"AVALON_MONGO": self.avalon_mongo_url,
# TODO thumbnails root should be multiplafrom
# - thumbnails root
"AVALON_THUMBNAIL_ROOT": self.thumbnail_root,
# - mongo timeout in ms
"AVALON_TIMEOUT": str(self.avalon_mongo_timeout),
# May be modifiable?
# - mongo database name where projects are stored
"AVALON_DB": "avalon"
}
def tray_init(self):

View file

@ -1,13 +1,11 @@
{
"avalon": {
"AVALON_MONGO": "",
"AVALON_TIMEOUT": 1000,
"AVALON_THUMBNAIL_ROOT": {
"windows": "",
"darwin": "",
"linux": ""
},
"AVALON_DB_DATA": "{PYPE_SETUP_PATH}/../mongo_db_data"
}
},
"ftrack": {
"enabled": true,

View file

@ -11,12 +11,6 @@
"label": "Avalon",
"collapsible": true,
"children": [
{
"type": "text",
"key": "AVALON_MONGO",
"label": "Avalon Mongo URL",
"placeholder": "Pype Mongo is used if not filled."
},
{
"type": "number",
"key": "AVALON_TIMEOUT",
@ -29,11 +23,6 @@
"key": "AVALON_THUMBNAIL_ROOT",
"multiplatform": true,
"multipath": false
},
{
"type": "text",
"key": "AVALON_DB_DATA",
"label": "Avalon Mongo Data Location"
}
]
},

View file

@ -175,6 +175,38 @@ def run(arguments: list, env: dict = None) -> int:
return p.returncode
def set_avalon_environments():
"""Set avalon specific environments.
These are non modifiable environments for avalon workflow that must be set
before avalon module is imported because avalon works with globals set with
environment variables.
"""
from pype import PACKAGE_DIR
# Path to pype's schema
schema_path = os.path.join(
os.path.dirname(PACKAGE_DIR),
"schema"
)
# Avalon mongo URL
avalon_mongo_url = (
os.environ.get("AVALON_MONGO")
or os.environ["PYPE_MONGO"]
)
os.environ.update({
# Mongo url (use same as pype has)
"AVALON_MONGO": avalon_mongo_url,
"AVALON_SCHEMA": schema_path,
# Mongo DB name where avalon docs are stored
"AVALON_DB": "avalon",
# Name of config
"AVALON_CONFIG": "pype",
"AVALON_LABEL": "Pype"
})
def set_modules_environments():
"""Set global environments for pype modules.
@ -548,6 +580,8 @@ def boot():
from pype.lib import terminal as t
from pype.version import __version__
print(">>> loading environments ...")
# Must happen before `set_modules_environments`
set_avalon_environments()
set_modules_environments()
assert version_path, "Version path not defined."