♻️ remove staging logic

This commit is contained in:
Ondrej Samohel 2022-10-13 11:34:57 +02:00
parent ed6cadb22b
commit 84b3bc3db2
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
4 changed files with 54 additions and 93 deletions

104
start.py
View file

@ -516,8 +516,6 @@ def _process_arguments() -> tuple:
if m and m.group('version'):
use_version = m.group('version')
_print(f">>> Requested version [ {use_version} ]")
if "+staging" in use_version:
use_staging = True
break
if use_version is None:
@ -682,8 +680,7 @@ def _find_frozen_openpype(use_version: str = None,
Path: Path to version to be used.
Raises:
RuntimeError: If no OpenPype version are found or no staging version
(if requested).
RuntimeError: If no OpenPype version are found.
"""
# Collect OpenPype versions
@ -698,13 +695,10 @@ def _find_frozen_openpype(use_version: str = None,
if use_version.lower() == "latest":
# Version says to use latest version
_print(">>> Finding latest version defined by use version")
openpype_version = bootstrap.find_latest_openpype_version(
use_staging)
openpype_version = bootstrap.find_latest_openpype_version()
else:
_print(f">>> Finding specified version \"{use_version}\"")
openpype_version = bootstrap.find_openpype_version(
use_version, use_staging
)
openpype_version = bootstrap.find_openpype_version(use_version)
if openpype_version is None:
raise OpenPypeVersionNotFound(
@ -714,8 +708,7 @@ def _find_frozen_openpype(use_version: str = None,
elif studio_version is not None:
# Studio has defined a version to use
_print(f">>> Finding studio version \"{studio_version}\"")
openpype_version = bootstrap.find_openpype_version(
studio_version, use_staging)
openpype_version = bootstrap.find_openpype_version(studio_version)
if openpype_version is None:
raise OpenPypeVersionNotFound((
"Requested OpenPype version "
@ -728,20 +721,15 @@ def _find_frozen_openpype(use_version: str = None,
_print((
">>> Finding latest version "
f"with [ {installed_version} ]"))
openpype_version = bootstrap.find_latest_openpype_version(
use_staging)
openpype_version = bootstrap.find_latest_openpype_version()
if openpype_version is None:
if use_staging:
reason = "Didn't find any staging versions."
else:
reason = "Didn't find any versions."
raise OpenPypeVersionNotFound(reason)
raise OpenPypeVersionNotFound("Didn't find any versions.")
# get local frozen version and add it to detected version so if it is
# newer it will be used instead.
if installed_version == openpype_version:
version_path = _bootstrap_from_code(use_version, use_staging)
version_path = _bootstrap_from_code(use_version)
openpype_version = OpenPypeVersion(
version=BootstrapRepos.get_version(version_path),
path=version_path)
@ -805,8 +793,8 @@ def _find_frozen_openpype(use_version: str = None,
return openpype_version.path
def _bootstrap_from_code(use_version, use_staging):
"""Bootstrap live code (or the one coming with frozen OpenPype.
def _bootstrap_from_code(use_version):
"""Bootstrap live code (or the one coming with frozen OpenPype).
Args:
use_version: (str): specific version to use.
@ -829,33 +817,25 @@ def _bootstrap_from_code(use_version, use_staging):
local_version = bootstrap.get_version(Path(_openpype_root))
switch_str = f" - will switch to {use_version}" if use_version and use_version != local_version else "" # noqa
_print(f" - booting version: {local_version}{switch_str}")
assert local_version
if not local_version:
raise OpenPypeVersionNotFound(
f"Cannot find version at {_openpype_root}")
else:
# get current version of OpenPype
local_version = OpenPypeVersion.get_installed_version_str()
# All cases when should be used different version than build
if (use_version and use_version != local_version) or use_staging:
if use_version and use_version != local_version:
if use_version:
# Explicit version should be used
version_to_use = bootstrap.find_openpype_version(
use_version, use_staging
)
version_to_use = bootstrap.find_openpype_version(use_version)
if version_to_use is None:
raise OpenPypeVersionIncompatible(
f"Requested version \"{use_version}\" was not found.")
else:
# Staging version should be used
version_to_use = bootstrap.find_latest_openpype_version(
use_staging
)
version_to_use = bootstrap.find_latest_openpype_version()
if version_to_use is None:
if use_staging:
reason = "Didn't find any staging versions."
else:
# This reason is backup for possible bug in code
reason = "Didn't find any versions."
raise OpenPypeVersionNotFound(reason)
raise OpenPypeVersionNotFound("Didn't find any versions.")
# Start extraction of version if needed
if version_to_use.path.is_file():
@ -913,10 +893,7 @@ def _bootstrap_from_code(use_version, use_staging):
def _boot_validate_versions(use_version, local_version):
_print(f">>> Validating version [ {use_version} ]")
openpype_versions = bootstrap.find_openpype(include_zips=True,
staging=True)
openpype_versions += bootstrap.find_openpype(include_zips=True,
staging=False)
openpype_versions = bootstrap.find_openpype(include_zips=True)
v: OpenPypeVersion
found = [v for v in openpype_versions if str(v) == use_version]
if not found:
@ -932,14 +909,7 @@ def _boot_validate_versions(use_version, local_version):
_print(f'{">>> " if valid else "!!! "}{message}')
def _boot_print_versions(use_staging, local_version, openpype_root):
if not use_staging:
_print("--- This will list only non-staging versions detected.")
_print(" To see staging versions, use --use-staging argument.")
else:
_print("--- This will list only staging versions detected.")
_print(" To see other version, omit --use-staging argument.")
def _boot_print_versions(openpype_root):
if getattr(sys, 'frozen', False):
local_version = bootstrap.get_version(Path(openpype_root))
else:
@ -947,16 +917,12 @@ def _boot_print_versions(use_staging, local_version, openpype_root):
compatible_with = OpenPypeVersion(version=local_version)
if "--all" in sys.argv:
compatible_with = None
_print("--- Showing all version (even those not compatible).")
else:
_print(("--- Showing only compatible versions "
f"with [ {compatible_with.major}.{compatible_with.minor} ]"))
openpype_versions = bootstrap.find_openpype(
include_zips=True,
staging=use_staging,
)
openpype_versions = bootstrap.find_openpype(include_zips=True)
openpype_versions = [
version for version in openpype_versions
if version.is_compatible(
@ -966,12 +932,11 @@ def _boot_print_versions(use_staging, local_version, openpype_root):
list_versions(openpype_versions, local_version)
def _boot_handle_missing_version(local_version, use_staging, message):
def _boot_handle_missing_version(local_version, message):
_print(message)
if os.environ.get("OPENPYPE_HEADLESS_MODE") == "1":
openpype_versions = bootstrap.find_openpype(
include_zips=True, staging=use_staging
)
include_zips=True)
list_versions(openpype_versions, local_version)
else:
igniter.show_message_dialog("Version not found", message)
@ -1005,7 +970,6 @@ def boot():
"is overridden by command line argument."))
else:
_print(">>> version set by environment variable")
use_staging = "staging" in os.getenv("OPENPYPE_VERSION")
use_version = os.getenv("OPENPYPE_VERSION")
# ------------------------------------------------------------------------
@ -1059,7 +1023,7 @@ def boot():
os.environ["OPENPYPE_PATH"] = openpype_path
if "print_versions" in commands:
_boot_print_versions(use_staging, local_version, OPENPYPE_ROOT)
_boot_print_versions(OPENPYPE_ROOT)
sys.exit(1)
# ------------------------------------------------------------------------
@ -1072,7 +1036,7 @@ def boot():
try:
version_path = _find_frozen_openpype(use_version, use_staging)
except OpenPypeVersionNotFound as exc:
_boot_handle_missing_version(local_version, use_staging, str(exc))
_boot_handle_missing_version(local_version, str(exc))
sys.exit(1)
except RuntimeError as e:
@ -1088,10 +1052,10 @@ def boot():
_print("--- version is valid")
else:
try:
version_path = _bootstrap_from_code(use_version, use_staging)
version_path = _bootstrap_from_code(use_version)
except OpenPypeVersionNotFound as exc:
_boot_handle_missing_version(local_version, use_staging, str(exc))
_boot_handle_missing_version(local_version, str(exc))
sys.exit(1)
# set this to point either to `python` from venv in case of live code
@ -1172,10 +1136,10 @@ def get_info(use_staging=None) -> list:
inf.append(("OpenPype variant", "staging"))
else:
inf.append(("OpenPype variant", "production"))
inf.append(
("Running OpenPype from", os.environ.get('OPENPYPE_REPOS_ROOT'))
inf.extend([
("Running OpenPype from", os.environ.get('OPENPYPE_REPOS_ROOT')),
("Using mongodb", components["host"])]
)
inf.append(("Using mongodb", components["host"]))
if os.environ.get("FTRACK_SERVER"):
inf.append(("Using FTrack at",
@ -1194,11 +1158,13 @@ def get_info(use_staging=None) -> list:
mongo_components = get_default_components()
if mongo_components["host"]:
inf.append(("Logging to MongoDB", mongo_components["host"]))
inf.append((" - port", mongo_components["port"] or "<N/A>"))
inf.append((" - database", Logger.log_database_name))
inf.append((" - collection", Logger.log_collection_name))
inf.append((" - user", mongo_components["username"] or "<N/A>"))
inf.extend([
("Logging to MongoDB", mongo_components["host"]),
(" - port", mongo_components["port"] or "<N/A>"),
(" - database", Logger.log_database_name),
(" - collection", Logger.log_collection_name),
(" - user", mongo_components["username"] or "<N/A>")
])
if mongo_components["auth_db"]:
inf.append((" - auth source", mongo_components["auth_db"]))