added option to pass global settings to 'get_expected_studio_version_str'

This commit is contained in:
iLLiCiTiT 2021-12-09 12:13:36 +01:00
parent 070078d157
commit 43c552dbbf
2 changed files with 11 additions and 4 deletions

View file

@ -591,19 +591,22 @@ class OpenPypeVersion(semver.VersionInfo):
return all_versions[-1]
@classmethod
def get_expected_studio_version(cls, staging=False):
def get_expected_studio_version(cls, staging=False, global_settings=None):
"""Expected OpenPype version that should be used at the moment.
If version is not defined in settings the latest found version is
used.
Using precached global settings is needed for usage inside OpenPype.
Args:
staging (bool): Staging version or production version.
global_settings (dict): Optional precached global settings.
Returns:
OpenPypeVersion: Version that should be used.
"""
result = get_expected_studio_version_str(staging)
result = get_expected_studio_version_str(staging, global_settings)
if not result:
return None
return OpenPypeVersion(version=result)

View file

@ -187,17 +187,21 @@ def get_openpype_path_from_db(url: str) -> Union[str, None]:
return None
def get_expected_studio_version_str(staging=False) -> str:
def get_expected_studio_version_str(
staging=False, global_settings=None
) -> str:
"""Version that should be currently used in studio.
Args:
staging (bool): Get current version for staging.
global_settings (dict): Optional precached global settings.
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 global_settings is None:
global_settings = get_openpype_global_settings(mongo_url)
if staging:
key = "staging_version"
else: