added functions to get expected studio version

This commit is contained in:
iLLiCiTiT 2021-12-06 11:51:35 +01:00
parent 7aec21aa80
commit 8f0f076980
2 changed files with 40 additions and 1 deletions

View file

@ -22,7 +22,10 @@ from .user_settings import (
OpenPypeSecureRegistry,
OpenPypeSettingsRegistry
)
from .tools import get_openpype_path_from_db
from .tools import (
get_openpype_path_from_db,
get_expected_studio_version_str
)
LOG_INFO = 0
@ -571,6 +574,24 @@ class OpenPypeVersion(semver.VersionInfo):
return openpype_versions[-1]
@classmethod
def get_expected_studio_version(cls, staging=False):
"""Expected OpenPype version that should be used at the moment.
If version is not defined in settings the latest found version is
used.
Args:
staging (bool): Staging version or production version.
Returns:
OpenPypeVersion: Version that should be used.
"""
result = get_expected_studio_version_str(staging)
if not result:
return cls.get_latest_version(staging, False)
return OpenPypeVersion(version=result)
class BootstrapRepos:
"""Class for bootstrapping local OpenPype installation.

View file

@ -182,6 +182,24 @@ def get_openpype_path_from_db(url: str) -> Union[str, None]:
return None
def get_expected_studio_version_str(staging=False) -> str:
"""Version that should be currently used in studio.
Args:
staging (bool): Get current version for staging.
Returns:
str: OpenPype version which should be used. Empty string means latest.
"""
mongo_url = os.environ.get("OPENPYPE_MONGO")
global_settings = get_openpype_global_settings(mongo_url)
if staging:
key = "staging_version"
else:
key = "production_version"
return global_settings.get(key) or ""
def load_stylesheet() -> str:
"""Load css style sheet.