diff --git a/igniter/bootstrap_repos.py b/igniter/bootstrap_repos.py index 94f786e869..9446b3e8ce 100644 --- a/igniter/bootstrap_repos.py +++ b/igniter/bootstrap_repos.py @@ -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. diff --git a/igniter/tools.py b/igniter/tools.py index 3e862f5803..5cad2b9bf8 100644 --- a/igniter/tools.py +++ b/igniter/tools.py @@ -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.