Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/3.15.x' into feature/OP-3426_Add-support-for-De…
Browse files Browse the repository at this point in the history
…adline-for-automatic-tests
  • Loading branch information
kalisp authored Nov 11, 2022
2 parents 40d2571 + 86cd0e6 commit 41f4c39
Show file tree
Hide file tree
Showing 22 changed files with 330 additions and 443 deletions.
227 changes: 27 additions & 200 deletions igniter/bootstrap_repos.py

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions igniter/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ def get_openpype_path_from_settings(settings: dict) -> Union[str, None]:
if paths and isinstance(paths, str):
paths = [paths]

# Loop over paths and return only existing
for path in paths:
if os.path.exists(path):
return path
return None
return next((path for path in paths if os.path.exists(path)), None)


def get_expected_studio_version_str(
Expand All @@ -207,10 +203,7 @@ def get_expected_studio_version_str(
mongo_url = os.environ.get("OPENPYPE_MONGO")
if global_settings is None:
global_settings = get_openpype_global_settings(mongo_url)
if staging:
key = "staging_version"
else:
key = "production_version"
key = "staging_version" if staging else "production_version"
return global_settings.get(key) or ""


Expand Down
15 changes: 6 additions & 9 deletions openpype/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
@click.option("--use-staging", is_flag=True,
expose_value=False, help="use staging variants")
@click.option("--list-versions", is_flag=True, expose_value=False,
help=("list all detected versions. Use With `--use-staging "
"to list staging versions."))
help="list all detected versions.")
@click.option("--validate-version", expose_value=False,
help="validate given version integrity")
@click.option("--debug", is_flag=True, expose_value=False,
help=("Enable debug"))
help="Enable debug")
@click.option("--verbose", expose_value=False,
help=("Change OpenPype log level (debug - critical or 0-50)"))
@click.option("--automatic-tests", is_flag=True, expose_value=False,
Expand Down Expand Up @@ -425,20 +424,18 @@ def unpack_project(zipfile, root):

@main.command()
def interactive():
"""Interative (Python like) console.
"""Interactive (Python like) console.
Helpfull command not only for development to directly work with python
Helpful command not only for development to directly work with python
interpreter.
Warning:
Executable 'openpype_gui' on windows won't work.
Executable 'openpype_gui' on Windows won't work.
"""

from openpype.version import __version__

banner = "OpenPype {}\nPython {} on {}".format(
__version__, sys.version, sys.platform
)
banner = f"OpenPype {__version__}\nPython {sys.version} on {sys.platform}"
code.interact(banner)


Expand Down
2 changes: 1 addition & 1 deletion openpype/hosts/standalonepublisher/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class StandAlonePublishAddon(OpenPypeModule, ITrayAction, IHostAddon):
label = "Publish"
label = "Publisher (legacy)"
name = "standalonepublisher"
host_name = "standalonepublisher"

Expand Down
15 changes: 2 additions & 13 deletions openpype/hosts/traypublisher/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class TrayPublishAddon(OpenPypeModule, IHostAddon, ITrayAction):
label = "New Publish (beta)"
label = "Publisher"
name = "traypublisher"
host_name = "traypublisher"

Expand All @@ -19,20 +19,9 @@ def initialize(self, modules_settings):
self.publish_paths = [
os.path.join(TRAYPUBLISH_ROOT_DIR, "plugins", "publish")
]
self._experimental_tools = None

def tray_init(self):
from openpype.tools.experimental_tools import ExperimentalTools

self._experimental_tools = ExperimentalTools()

def tray_menu(self, *args, **kwargs):
super(TrayPublishAddon, self).tray_menu(*args, **kwargs)
traypublisher = self._experimental_tools.get("traypublisher")
visible = False
if traypublisher and traypublisher.enabled:
visible = True
self._action_item.setVisible(visible)
return

def on_action_trigger(self):
self.run_traypublisher()
Expand Down
3 changes: 3 additions & 0 deletions openpype/lib/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ def get_app_environments_for_context(

from openpype.modules import ModulesManager
from openpype.pipeline import AvalonMongoDB, Anatomy
from openpype.lib.openpype_version import is_running_staging

# Avalon database connection
dbcon = AvalonMongoDB()
Expand Down Expand Up @@ -1404,6 +1405,8 @@ def get_app_environments_for_context(
"env": env
})
data["env"].update(anatomy.root_environments())
if is_running_staging():
data["env"]["OPENPYPE_IS_STAGING"] = "1"

prepare_app_environments(data, env_group, modules_manager)
prepare_context_environments(data, env_group, modules_manager)
Expand Down
69 changes: 59 additions & 10 deletions openpype/lib/openpype_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,66 @@ def is_running_from_build():
return True


def is_staging_enabled():
return os.environ.get("OPENPYPE_USE_STAGING") == "1"


def is_running_staging():
"""Currently used OpenPype is staging version.
This function is not 100% proper check of staging version. It is possible
to have enabled to use staging version but be in different one.
The function is based on 4 factors:
- env 'OPENPYPE_IS_STAGING' is set
- current production version
- current staging version
- use staging is enabled
First checks for 'OPENPYPE_IS_STAGING' environment which can be set to '1'.
The value should be set only when a process without access to
OpenPypeVersion is launched (e.g. in DCCs). If current version is same
as production version it is expected that it is not staging, and it
doesn't matter what would 'is_staging_enabled' return. If current version
is same as staging version it is expected we're in staging. In all other
cases 'is_staging_enabled' is used as source of outpu value.
The function is used to decide which icon is used. To check e.g. updates
the output should be combined with other functions from this file.
Returns:
bool: True if openpype version containt 'staging'.
bool: Using staging version or not.
"""
if "staging" in get_openpype_version():

if os.environ.get("OPENPYPE_IS_STAGING") == "1":
return True

if not op_version_control_available():
return False

from openpype.settings import get_global_settings

global_settings = get_global_settings()
production_version = global_settings["production_version"]
latest_version = None
if not production_version or production_version == "latest":
latest_version = get_latest_version(local=False, remote=True)
production_version = latest_version

current_version = get_openpype_version()
if current_version == production_version:
return False

staging_version = global_settings["staging_version"]
if not staging_version or staging_version == "latest":
if latest_version is None:
latest_version = get_latest_version(local=False, remote=True)
staging_version = latest_version

if current_version == production_version:
return True
return False

return is_staging_enabled()


# ----------------------------------------
Expand Down Expand Up @@ -131,13 +182,11 @@ def get_remote_versions(*args, **kwargs):
return None


def get_latest_version(staging=None, local=None, remote=None):
def get_latest_version(local=None, remote=None):
"""Get latest version from repository path."""
if staging is None:
staging = is_running_staging()

if op_version_control_available():
return get_OpenPypeVersion().get_latest_version(
staging=staging,
local=local,
remote=remote
)
Expand All @@ -146,9 +195,9 @@ def get_latest_version(staging=None, local=None, remote=None):

def get_expected_studio_version(staging=None):
"""Expected production or staging version in studio."""
if staging is None:
staging = is_running_staging()
if op_version_control_available():
if staging is None:
staging = is_staging_enabled()
return get_OpenPypeVersion().get_expected_studio_version(staging)
return None

Expand All @@ -158,7 +207,7 @@ def get_expected_version(staging=None):
if expected_version is None:
# Look for latest if expected version is not set in settings
expected_version = get_latest_version(
staging=staging,
local=False,
remote=True
)
return expected_version
Expand Down
14 changes: 10 additions & 4 deletions openpype/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ def get_liberation_font_path(bold=False, italic=False):
return font_path


def get_openpype_production_icon_filepath():
return get_resource("icons", "openpype_icon.png")


def get_openpype_staging_icon_filepath():
return get_resource("icons", "openpype_icon_staging.png")


def get_openpype_icon_filepath(staging=None):
if staging is None:
staging = is_running_staging()

if staging:
icon_file_name = "openpype_icon_staging.png"
else:
icon_file_name = "openpype_icon.png"
return get_resource("icons", icon_file_name)
return get_openpype_staging_icon_filepath()
return get_openpype_production_icon_filepath()


def get_openpype_splash_filepath(staging=None):
Expand Down
4 changes: 3 additions & 1 deletion openpype/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
)
from .lib import (
get_general_environments,
get_global_settings,
get_system_settings,
get_project_settings,
get_current_project_settings,
get_anatomy_settings,
get_local_settings
get_local_settings,
)
from .entities import (
SystemSettings,
Expand All @@ -49,6 +50,7 @@
"SaveWarningExc",

"get_general_environments",
"get_global_settings",
"get_system_settings",
"get_project_settings",
"get_current_project_settings",
Expand Down
2 changes: 1 addition & 1 deletion openpype/settings/defaults/system_settings/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"enabled": true
},
"standalonepublish_tool": {
"enabled": true
"enabled": false
},
"project_manager": {
"enabled": true
Expand Down
8 changes: 2 additions & 6 deletions openpype/settings/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@
)

from .anatomy_entities import AnatomyEntity
from .op_version_entity import (
ProductionVersionsInputEntity,
StagingVersionsInputEntity
)
from .op_version_entity import VersionsInputEntity

__all__ = (
"DefaultsNotDefined",
Expand Down Expand Up @@ -188,6 +185,5 @@

"AnatomyEntity",

"ProductionVersionsInputEntity",
"StagingVersionsInputEntity"
"VersionsInputEntity",
)
17 changes: 3 additions & 14 deletions openpype/settings/entities/op_version_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,13 @@ def convert_to_valid_type(self, value):
return super(OpenPypeVersionInput, self).convert_to_valid_type(value)


class ProductionVersionsInputEntity(OpenPypeVersionInput):
class VersionsInputEntity(OpenPypeVersionInput):
"""Entity meant only for global settings to define production version."""
schema_types = ["production-versions-text"]
schema_types = ["versions-text"]

def _get_openpype_versions(self):
versions = get_remote_versions(staging=False, production=True)
versions = get_remote_versions()
if versions is None:
return []
versions.append(get_installed_version())
return sorted(versions)


class StagingVersionsInputEntity(OpenPypeVersionInput):
"""Entity meant only for global settings to define staging version."""
schema_types = ["staging-versions-text"]

def _get_openpype_versions(self):
versions = get_remote_versions(staging=True, production=False)
if versions is None:
return []
return sorted(versions)
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@
"label": "Define explicit OpenPype version that should be used. Keep empty to use latest available version."
},
{
"type": "production-versions-text",
"type": "versions-text",
"key": "production_version",
"label": "Production version"
},
{
"type": "staging-versions-text",
"type": "versions-text",
"key": "staging_version",
"label": "Staging version"
},
Expand Down
Loading

0 comments on commit 41f4c39

Please sign in to comment.