Skip to content

Commit

Permalink
SHOT-3770 ShotGrid rebrand (#70)
Browse files Browse the repository at this point in the history
* Support plugin name change to ShotGrid.

* Added integer comparison for ShotGrid menu.

* Rebuilt plugins to contain v2.1.1 as TERAGET_VERSION

* Fixed typo in error message.

* Rebuilt alias_api.pyd objects to contain v2.1.1 as TARGET_VERSION

* Added 2020.2.2 max for SHOT-3719

* Pre-commit hook updates

* PR comments addressed - new _version_check and comments removed

* PR changes for doc of _version_check
  • Loading branch information
rob-aitchison authored Jul 26, 2021
1 parent 7a5c3ec commit 8d8fd2f
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 14 deletions.
Binary file modified api/python2/alias2019-alias2020.2/alias_api.pyd
Binary file not shown.
Binary file modified api/python2/alias2020.3-alias2021/alias_api.pyd
Binary file not shown.
Binary file modified api/python2/alias2021.3/alias_api.pyd
Binary file not shown.
Binary file modified api/python3/alias2019-alias2020.2/alias_api.pyd
Binary file not shown.
Binary file modified api/python3/alias2020.3-alias2021/alias_api.pyd
Binary file not shown.
Binary file modified api/python3/alias2021.3/alias_api.pyd
Binary file not shown.
29 changes: 24 additions & 5 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import sgtk
from sgtk.util import LocalFileStorageManager

import alias_api


Expand All @@ -30,6 +31,7 @@ def __init__(self, tk, context, engine_instance_name, env):
self.alias_codename = None
self.alias_execpath = None
self.alias_bindir = None
self.alias_version = None
self._dialog_parent = None

self._menu_generator = None
Expand Down Expand Up @@ -132,19 +134,36 @@ def pre_app_init(self):
self.alias_codename = os.getenv("TK_ALIAS_CODENAME", "autostudio")

# Be sure the current version is supported
alias_version = int(os.getenv("TK_ALIAS_VERSION", None))
if not alias_version:
self.alias_version = os.getenv("TK_ALIAS_VERSION", None)
if not self.alias_version:
self.logger.debug("Couldn't get Alias version. Skip version comparison")
return

if alias_version > self.get_setting("compatibility_dialog_min_version", 2021):
if int(self.alias_version[0:4]) > self.get_setting(
"compatibility_dialog_min_version", 2021
):
from sgtk.platform.qt import QtGui

msg = (
"The ShotGrid Pipeline Toolkit has not yet been fully tested with Alias %d. "
"The ShotGrid Pipeline Toolkit has not yet been fully tested with Alias %s. "
"You can continue to use the Toolkit but you may experience bugs or "
"instability. Please report any issues you see to %s"
% (alias_version, sgtk.support_url)
% (self.alias_version, sgtk.support_url)
)
self.logger.warning(msg)
QtGui.QMessageBox.warning(
self.get_parent_window(), "Warning - ShotGrid Pipeline Toolkit!", msg,
)
elif int(self.alias_version[0:4]) < 2021 and self.get_setting(
"compatibility_dialog_old_version"
):
from sgtk.platform.qt import QtGui

msg = (
"The ShotGrid Pipeline Toolkit is not fully capable with Alias %s. "
"You should consider upgrading to a more recent version of Alias. "
"Please report any issues you see to %s"
% (self.alias_version, sgtk.support_url)
)
self.logger.warning(msg)
QtGui.QMessageBox.warning(
Expand Down
5 changes: 5 additions & 0 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ configuration:
value to the current major version + 1."
default_value: 2022

compatibility_dialog_old_version:
type: bool
description: "Disable warning about older versions of Alias"
default_value: True

# the Shotgun fields that this engine needs in order to operate correctly
requires_shotgun_fields:

Expand Down
Binary file added plugins/shotgrid.plugin
Binary file not shown.
Binary file added plugins/shotgrid_py2.plugin
Binary file not shown.
Binary file modified plugins/shotgun.plugin
Binary file not shown.
Binary file modified plugins/shotgun_legacy.plugin
Binary file not shown.
Binary file modified plugins/shotgun_legacy_py2.plugin
Binary file not shown.
Binary file modified plugins/shotgun_py2.plugin
Binary file not shown.
47 changes: 44 additions & 3 deletions python/tk_alias/menu_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class AliasMenuGenerator(object):
Menu handling for Alias.
"""

MENU_NAME = "al_shotgun"

def __init__(self, engine):
"""
Initializes a new menu generator.
Expand All @@ -31,6 +29,10 @@ def __init__(self, engine):
:type engine: :class:`tank.platform.Engine`
"""
self._engine = engine
if self._version_check(engine.alias_version, "2022.2") >= 0:
self.MENU_NAME = "al_shotgrid"
else:
self.MENU_NAME = "al_shotgun"
self._alias_menu = alias_api.Menu(self.MENU_NAME)

def create_menu(self, clean_menu=True):
Expand All @@ -41,7 +43,7 @@ def create_menu(self, clean_menu=True):
new one. This is useful in the case you're rebuilding the menu after context switching.
"""

# First, ensure that the Shotgun menu inside Alias is empty.
# First, ensure that the ShotGrid menu inside Alias is empty.
# This is to ensure we can recover from weird context switches
# where the engine didn't clean up after itself properly.
if clean_menu:
Expand Down Expand Up @@ -186,6 +188,45 @@ def _jump_to_fs(self):
if exit_code != 0:
self._engine.logger.error("Failed to launch '%s'!", cmd)

def _version_check(self, version1, version2):
"""
Compare version strings and return 1 if version1 is greater than version2,
0 if they are equal and -1 if version1 is less than version2
:param version1: A version string to compare against version2 e.g. 2022.2
:param version2: A version string to compare against version1 e.g. 2021.3.1
:return: 1, 0, -1 as per above.
"""
# This will split both the versions by the '.' character
arr1 = version1.split(".")
arr2 = version2.split(".")
n = len(arr1)
m = len(arr2)

# Converts to integer from string
arr1 = [int(i) for i in arr1]
arr2 = [int(i) for i in arr2]

# Compares which list is bigger and fills
# the smaller list with zero (for unequal delimeters)
if n > m:
for i in range(m, n):
arr2.append(0)
elif m > n:
for i in range(n, m):
arr1.append(0)

# Returns 1 if version1 is greater
# Returns -1 if version2 is greater
# Returns 0 if they are equal
for i in range(len(arr1)):
if arr1[i] > arr2[i]:
return 1
elif arr2[i] > arr1[i]:
return -1
return 0

def refresh(self):
"""
Refresh the menu by forcing Alias to rebuild of its menus.
Expand Down
22 changes: 16 additions & 6 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ class AliasLauncher(SoftwareLauncher):
# Fallback code name to use when none is given
FALLBACK_CODE_NAME = "AutoStudio"

# Shotgun default plugins
# ShotGrid default plugins
DEFAULT_PLUGINS = {
"shotgun.plugin": {"min_version": "2020.2", "python_major_version": 3},
"shotgun_py2.plugin": {"min_version": "2020.2", "python_major_version": 2},
"shotgrid.plugin": {"min_version": "2022.2", "python_major_version": 3},
"shotgrid_py2.plugin": {"min_version": "2022.2", "python_major_version": 2},
"shotgun.plugin": {
"min_version": "2020.2",
"max_version": "2022.1",
"python_major_version": 3,
},
"shotgun_py2.plugin": {
"min_version": "2020.2",
"max_version": "2022.1",
"python_major_version": 2,
},
"shotgun_legacy.plugin": {
"min_version": "2019",
"max_version": "2020.1",
Expand All @@ -63,7 +73,7 @@ class AliasLauncher(SoftwareLauncher):
ALIAS_API = {
"alias2021.3": {"min_version": "2021.3"},
"alias2020.3-alias2021": {"min_version": "2020.3", "max_version": "2021.2.2"},
"alias2019-alias2020.2": {"min_version": "2019", "max_version": "2020.2"},
"alias2019-alias2020.2": {"min_version": "2019", "max_version": "2020.2.2"},
}

# This dictionary defines a list of executable template strings for each
Expand Down Expand Up @@ -152,12 +162,12 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
tk_alias_codename_lower = tk_alias_codename.lower()
required_env["TK_ALIAS_VERSION"] = self._get_release_version(
exec_path, tk_alias_codename
).split(".")[0]
)
else:
tk_alias_codename_lower = self.FALLBACK_CODE_NAME.lower()
required_env["TK_ALIAS_VERSION"] = self._get_release_version(
exec_path, self.FALLBACK_CODE_NAME
).split(".")[0]
)

required_env["TK_ALIAS_CODENAME"] = tk_alias_codename_lower

Expand Down

0 comments on commit 8d8fd2f

Please sign in to comment.