diff --git a/python/tk_desktop/desktop_engine_project_implementation.py b/python/tk_desktop/desktop_engine_project_implementation.py
index 1c9f5a25..bd329800 100644
--- a/python/tk_desktop/desktop_engine_project_implementation.py
+++ b/python/tk_desktop/desktop_engine_project_implementation.py
@@ -20,6 +20,7 @@
import fnmatch
import traceback
import threading
+from packaging.version import Version
from sgtk import LogManager
import sgtk
@@ -80,11 +81,167 @@ def post_app_init(self):
self._connect_to_server()
self._register_groups()
self._register_commands()
+ self._display_banners()
+
+
except:
# Same deal as during init_engine.
self.destroy_engine()
raise
+ def _display_banners(self):
+ """
+ Banner display for project-specific panel loading.
+
+ Message triggered by env var: SGTK_DESKTOP_PROJECT_BANNER_MESSAGE
+
+ Use env var: SGTK_DESKTOP_PROJECT_BANNER_ID if you wish for the banner
+ to be dismissed once and not bug the artist again. Otherwise the message
+ will be showed every time it's found in the environment and require the artist
+ to dismiss it each time.
+ If you want to implement a strategy for this ID, you
+ could use formatted time. To show the banner and only bug the user once a day,
+ assuming they dismiss it once a day, you could use the following with datetime.strftime:
+ - "myidnamespace.%Y%M%d",
+ or once a month, use:
+ - "myidnamespace.%Y%M"
+ By using a specific key, like "myidnamespace.1" it will never show up again if the
+ user has already dismissed it.
+ """
+ if os.getenv('SGTK_DESKTOP_PROJECT_BANNER_MESSAGE'):
+
+ banner_message = os.environ['SGTK_DESKTOP_PROJECT_BANNER_MESSAGE']
+ banner_id = None
+
+ if os.getenv('SGTK_DESKTOP_PROJECT_BANNER_ID'):
+ banner_id = os.environ['SGTK_DESKTOP_PROJECT_BANNER_ID']
+
+ # call back to the site implementation to show the banner
+ self._project_comm.call_no_response("update_banners", banner_message, banner_id)
+
+ # self._check_desktop_version()
+
+
+ def _check_desktop_version(self):
+ """
+ Checks the current Desktop version and displays a banner if it's less than 1.9.
+ """
+ try:
+ # Attempt to find the ShotGrid Desktop version in a couple of potential locations
+ current_version = "1.9"
+ engine = sgtk.platform.current_engine()
+ # logger.debug(">>>>>>>>>>> Current Engine: %s" % engine)
+ if engine:
+ current_version = engine.app_version
+ logger.debug(">>>>>>>>>>> Current Desktop version: %s" % current_version)
+ required_version = "1.9"
+
+ if current_version and Version(str(current_version)) <= Version(str(required_version)):
+ banner_message = (
+ "Autodesk disabled auto-updating due to Python version change. "
+ "Please download the new version here."
+ )
+ self._project_comm.call_no_response("update_banners", banner_message, "desktop_version_check")
+ else:
+ # Log a warning if the version could not be determined
+ self._engine.logger.debug("Could not determine the ShotGrid Desktop version.")
+ except Exception as e:
+ # Log an error if there was an exception
+ logger.debug("Error checking the ShotGrid Desktop version: %s" % e)
+
+ #from distutils.version import LooseVersion as Version
+
+ #from distutils.version import LooseVersion as Version
+ #import os
+
+ def _check_desktop_version_old6(self):
+ """
+ Checks the current Desktop version and displays a banner if it's less than 1.9.
+ """
+ try:
+ # Retrieve the version of "tk-desktop" from the sgtk object
+ desktop_engine_descriptor = self._engine.sgtk.descriptor.get_descriptor(
+ self._engine.sgtk.pipeline_configuration,
+ self._engine.sgtk.descriptor.Descriptor.ENGINE,
+ "tk-desktop"
+ )
+
+ current_version = desktop_engine_descriptor.version
+ logger.debug(">>>>>>>>>>> Current Desktop version: %s" % current_version)
+
+ required_version = "1.9"
+
+ if current_version and Version(str(current_version)) < Version(str(required_version)):
+ banner_message = (
+ "Autodesk disabled auto-updating due to Python version change. "
+ "Please download the new version here."
+ )
+ self._project_comm.call_no_response("update_banners", banner_message, "desktop_version_check")
+ else:
+ # Log a warning if the version could not be determined
+ self._engine.logger.warning("Could not determine the ShotGrid Desktop version.")
+ except Exception as e:
+ # Log an error if there was an exception
+ logger.debug(">>>>> Error checking the ShotGrid Desktop version: %s" % e)
+
+ def _check_desktop_version_old5(self):
+ """
+ Checks the current Desktop version and displays a banner if it's less than 1.9.
+ """
+ try:
+ # Ensure the engine is tk-desktop
+ engine = sgtk.platform.start_engine("tk-desktop", self._engine.sgtk, self._engine.context)
+ current_version = None
+
+ if engine:
+ current_version = engine.app_version
+ logger.debug(">>>>>>>>>>> Current Desktop version: %s" % current_version)
+ else:
+ logger.debug(">>>>>>>>>>> Could not start tk-desktop engine.")
+
+ required_version = "1.9"
+
+ if current_version and Version(str(current_version)) < Version(str(required_version)):
+ banner_message = (
+ "Autodesk disabled auto-updating due to Python version change. "
+ "Please download the new version here."
+ )
+ self._project_comm.call_no_response("update_banners", banner_message, "desktop_version_check")
+ else:
+ # Log a warning if the version could not be determined
+ self._engine.logger.warning("Could not determine the ShotGrid Desktop version.")
+ except Exception as e:
+ # Log an error if there was an exception
+ logger.debug("Error checking the ShotGrid Desktop version: %s" % e)
+
+ def _check_desktop_version_old2(self):
+ """
+ Checks the current Desktop version and displays a banner if it's less than 1.9.
+ """
+ # This assumes there's a method or property self._engine.get_desktop_version() to get the Desktop app version.
+ current_version = self._engine.get_desktop_version()
+ required_version = "1.9"
+
+ if Version(str(current_version)) < Version(str(required_version)):
+ banner_message = (
+ "Autodesk disabled auto-updating due to Python version change. "
+ "Please download the new version here."
+ )
+ self._project_comm.call_no_response("update_banners", banner_message, "desktop_version_check")
+ def _check_desktop_version_old(self):
+ """
+ Checks the current Desktop version and displays a banner if it's less than 1.9.
+ """
+ current_version = self._engine.sgtk.version
+ required_version = "1.9"
+
+ if Version(str(current_version)) < Version(str(required_version)):
+ banner_message = (
+ "Autodesk disabled auto-updating due to Python version change. "
+ "Please download the new version here."
+ )
+ self._project_comm.call_no_response("update_banners", banner_message, "desktop_version_check")
+
def _connect_to_server(self):
"""
Connects to the other process's server and starts our own.
diff --git a/python/tk_desktop/desktop_engine_site_implementation.py b/python/tk_desktop/desktop_engine_site_implementation.py
index ab757779..6d5c0a2b 100644
--- a/python/tk_desktop/desktop_engine_site_implementation.py
+++ b/python/tk_desktop/desktop_engine_site_implementation.py
@@ -207,6 +207,9 @@ def startup_rpc(self):
self.site_comm.register_function(
self.project_commands_finished, "project_commands_finished"
)
+ self.site_comm.register_function(
+ self.update_banners, "update_banners"
+ )
def engine_startup_error(self, exception_type, exception_str, tb=None):
"""
@@ -235,6 +238,31 @@ def _on_proxy_closing(self):
# Clear the UI, we can't launch anything anymore!
self.desktop_window.clear_app_uis()
+ def update_banners(self, banner_message=None, banner_id=None):
+ """
+ A workaround live banner updating caller that sets the engine settings
+ live. This will only be called if project specific functions use the env vars
+ SGTK_DESKTOP_PROJECT_BANNER_MESSAGE, SGTK_DESKTOP_PROJECT_BANNER_ID to set them
+ for triggering their update to view them.
+
+ This method can be called directly from commands in the project panes upon being clicked if
+ you utilize:
+
+ >> self.engine._project_comm.call_no_response("update_banners", "banner message here , "optional banner id here")
+ """
+
+ settings = self._engine.settings
+ if not banner_id:
+ import uuid
+ banner_id = str(uuid.uuid4())
+
+ settings['banner_id'] = banner_id
+ settings['banner_message'] = banner_message
+ self._engine._set_settings(settings)
+
+ self._engine.log_info("Forcing banner update...")
+ self.desktop_window._update_banners()
+
def _on_proxy_created(self):
"""
Invoked when background process has created proxy
diff --git a/python/tk_desktop/desktop_window.py b/python/tk_desktop/desktop_window.py
index fb5e2451..9a2a4e14 100644
--- a/python/tk_desktop/desktop_window.py
+++ b/python/tk_desktop/desktop_window.py
@@ -48,6 +48,8 @@
from .loading_project_widget import LoadingProjectWidget
from .browser_integration_user_switch_dialog import BrowserIntegrationUserSwitchDialog
from .banner_widget import BannerWidget
+from .desktop_engine_project_implementation import DesktopEngineProjectImplementation
+from .project_communication import ProjectCommunication
from .project_menu import ProjectMenu
from .command_panel import CommandPanel
@@ -57,6 +59,8 @@
from .extensions import osutils
+from packaging.version import Version
+
# import our frameworks
shotgun_model = sgtk.platform.import_framework(
"tk-framework-shotgunutils", "shotgun_model"
@@ -171,6 +175,7 @@ def __init__(self, console, parent=None):
self._sync_thread = None
engine = sgtk.platform.current_engine()
+ self._project_communication = ProjectCommunication(engine)
# setup the window
self.ui = desktop_window.Ui_DesktopWindow()
@@ -374,6 +379,7 @@ def __init__(self, console, parent=None):
# Do not put anything after this line, this can kick-off a Python process launch, which should
# be done only when the dialog is fully initialized.
self._load_settings()
+ self._handle_version_check()
def _debug_toggled(self, state):
"""
@@ -1720,6 +1726,7 @@ def open_site_in_browser(self):
def handle_about(self):
engine = sgtk.platform.current_engine()
+ # log.debug(">>>>> engine is: %s" % engine)
# If a Startup version was specified when engine.run was invoked
# it's because we're running the new installer code and therefore
@@ -1751,5 +1758,36 @@ def handle_about(self):
body += " {0} {1}
".format(name, version)
body += ""
+ # self._handle_version_check()
+
about = AboutScreen(parent=self, body=body)
about.exec_()
+
+ def _handle_version_check(self):
+ engine = sgtk.platform.current_engine()
+ log.debug(">>>>> engine is: %s" % engine)
+ app_version = engine.app_version
+ log.debug(">>>>> app version is: %s" % app_version)
+ self._check_desktop_version(app_version)
+
+ def _check_desktop_version(self, current_version):
+ """
+ Checks the current Desktop version and displays a banner if it's less than 1.9.
+ """
+ try:
+
+ required_version = "1.9"
+ log.debug(">>>>> required version is: %s" % required_version)
+ if current_version and Version(str(current_version)) <= Version(str(required_version)):
+ banner_message = (
+ "Autodesk disabled auto-updating due to Python version change. "
+ "Please download the new version here."
+ )
+ self._project_comm.call_no_response("update_banners", banner_message, "desktop_version_check")
+ else:
+ # Log a warning if the version could not be determined
+ self._engine.logger.debug("Could not determine the ShotGrid Desktop version.")
+ except Exception as e:
+ # Log an error if there was an exception
+ log.debug("Error checking the ShotGrid Desktop version: %s" % e)
+
diff --git a/python/tk_desktop/extensions/darwin_python310/osutils.cpython-310-darwin.so b/python/tk_desktop/extensions/darwin_python310/osutils.cpython-310-darwin.so
old mode 100755
new mode 100644
diff --git a/python/tk_desktop/extensions/darwin_python37/osutils.cpython-37m-darwin.so b/python/tk_desktop/extensions/darwin_python37/osutils.cpython-37m-darwin.so
old mode 100755
new mode 100644
diff --git a/python/tk_desktop/extensions/darwin_python39/osutils.cpython-39-darwin.so b/python/tk_desktop/extensions/darwin_python39/osutils.cpython-39-darwin.so
old mode 100755
new mode 100644