Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximumFX committed May 9, 2023
2 parents ca40a81 + f92b6b7 commit cccda56
Show file tree
Hide file tree
Showing 20 changed files with 195 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
- id: trailing-whitespace
# Leave black at the bottom so all touchups are done before it is run.
- repo: https://github.com/ambv/black
rev: 19.10b0
rev: 22.3.0
hooks:
- id: black
language_version: python3
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Python 2.6 2.7 3.7](https://img.shields.io/badge/python-2.6%20%7C%202.7%20%7C%203.7-blue.svg)](https://www.python.org/)
[![Python 2.7 3.7](https://img.shields.io/badge/python-2.7%20%7C%203.7-blue.svg)](https://www.python.org/)
[![Build Status](https://secure.travis-ci.org/shotgunsoftware/tk-nuke.png?branch=master)](http://travis-ci.org/shotgunsoftware/tk-nuke)
[![Build Status](https://dev.azure.com/shotgun-ecosystem/Toolkit/_apis/build/status/Engines/tk-nuke?branchName=master)](https://dev.azure.com/shotgun-ecosystem/Toolkit/_build/latest?definitionId=83&branchName=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Expand All @@ -8,14 +8,14 @@
This repository is a part of the ShotGrid Pipeline Toolkit.

- For more information about this app and for release notes, *see the wiki section*.
- For general information and documentation, click here: https://support.shotgunsoftware.com/entries/95441257
- For information about ShotGrid in general, click here: http://www.shotgunsoftware.com/toolkit
- For general information and documentation, click here: https://developer.shotgridsoftware.com/d587be80/?title=Integrations+User+Guide
- For information about ShotGrid in general, click here: https://www.shotgridsoftware.com/integrations

## Using this app in your Setup
All the apps that are part of our standard app suite are pushed to our App Store.
This is where you typically go if you want to install an app into a project you are
working on. For an overview of all the Apps and Engines in the Toolkit App Store,
click here: https://support.shotgunsoftware.com/entries/95441247.
click here: https://developer.shotgridsoftware.com/162eaa4b/?title=Pipeline+Integration+Components

## Have a Question?
Don't hesitate to contact us! You can find us on support@shotgunsoftware.com
Don't hesitate to contact us! You can find us on https://knowledge.autodesk.com/contact-support
146 changes: 95 additions & 51 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from __future__ import print_function
import sgtk
import nuke
import sys
import os
import nukescripts
import logging
Expand Down Expand Up @@ -180,10 +179,8 @@ def pre_app_init(self):
self.logger.error(msg)
return

# Versions > 13.1 have not yet been tested so show a message to that effect.
if nuke_version[0] > 13 or (
nuke_version[0] == 13 and nuke_version[1] > 2
):
# Versions > 14.0 have not yet been tested so show a message to that effect.
if nuke_version[0] > 14 or (nuke_version[0] == 14 and nuke_version[1] > 0):
# This is an untested version of Nuke.
msg = (
"The SG Pipeline Toolkit has not yet been fully tested with Nuke %d.%dv%d. "
Expand Down Expand Up @@ -264,6 +261,83 @@ def pre_app_init_nuke(self):
os.environ["TANK_ENGINE"] = self.instance_name
os.environ["TANK_CONTEXT"] = sgtk.context.serialize(self.context)

"""
https://jira.autodesk.com/browse/SG-25374
Weblogin does not show up in Nuke 11 and makes Nuke 12 and 13 to crash
To avoid Nuke crash, a monkeypatch of on_dialog_closed is required,
here the user is warned about restarted nuke is needed to continue.
"""
sgtk.authentication.sso_saml2.core.sso_saml2_core.SsoSaml2Core.on_dialog_closed = (
self._on_dialog_closed_monkeypatch
)

@staticmethod
def _on_dialog_closed_monkeypatch(self, result):
"""
Called whenever the dialog is dismissed.
This can be the result of a callback, a timeout or user interaction.
:param result: Qt result following the closing of the dialog.
QtGui.QDialog.Accepted or QtGui.QDialog.Rejected
"""
self._logger.debug("SSO dialog closed")
# pylint: disable=invalid-name
QtGui = self._QtGui # noqa

if self.is_handling_event():
if result == QtGui.QDialog.Rejected and self._session.cookies != "":
# We got here because of a timeout attempting a GUI-less login.
# Let's clear the cookies, and force the use of the GUI.
self._session.cookies = ""
# Let's have another go, without any cookies this time !
# This will force the GUI to be shown to the user.
self._logger.debug(
"Unable to login/renew claims automatically, presenting GUI "
"to user"
)
"""
https://jira.autodesk.com/browse/SG-25374
Weblogin does not show up in Nuke 11 and makes Nuke 12 and
13 to crash
"""
base_dir = os.path.dirname(os.path.abspath(__file__))

msgbox_icon = os.path.join(base_dir, "resources", "alert_icon.png")
msgbox_parent = self._dialog
msgbox_title = "Nuke"
msgbox_text = [
"The ShotGrid user session has expired.",
"To continue using ShotGrid in Nuke, please restart Nuke.",
]
msgbox_buttons = self._QtGui.QMessageBox.Ok

msgbox = self._QtGui.QMessageBox(msgbox_parent)
msgbox.setWindowTitle(msgbox_title)
msgbox.setText("\n\n".join(msgbox_text))
msgbox.setStandardButtons(msgbox_buttons)
msgbox.setIconPixmap(self._QtGui.QPixmap(msgbox_icon))
msgbox.activateWindow() # for Windows
msgbox.raise_() # for MacOS
msgbox.exec_()

status = QtGui.QDialog.Rejected
self._logger.warn("Skipping web login dialog for Nuke DCC.")
self._login_status = self._login_status or status
else:
self.resolve_event()
else:
# Should we get a rejected dialog, then we have had a timeout.
if result == QtGui.QDialog.Rejected:
# @FIXME: Figure out exactly what to do when we have a timeout.
self._logger.warn(
"Our QDialog got canceled outside of an event handling"
)

# Clear the web page
self._view.page().mainFrame().load("about:blank")

def post_app_init(self):
"""
Called when all apps have initialized.
Expand Down Expand Up @@ -309,9 +383,7 @@ def post_app_init_studio(self, menu_name="ShotGrid"):

# No context switching in plugin mode.
if self.in_plugin_mode:
self._context_switcher = tk_nuke.PluginStudioContextSwitcher(
self
)
self._context_switcher = tk_nuke.PluginStudioContextSwitcher(self)
else:
hiero.core.events.registerInterest(
"kAfterNewProjectCreated",
Expand All @@ -323,9 +395,7 @@ def post_app_init_studio(self, menu_name="ShotGrid"):
self._on_project_load_callback,
)

self._context_switcher = tk_nuke.ClassicStudioContextSwitcher(
self
)
self._context_switcher = tk_nuke.ClassicStudioContextSwitcher(self)
# On selection change we have to check what was selected and pre-load
# the context if that environment (ie: shot_step) hasn't already been
# processed. This ensure that all Nuke gizmos for the target environment
Expand Down Expand Up @@ -423,9 +493,7 @@ def post_app_init_nuke(self, menu_name="NFA ShotGrid"):
sgtk.util.append_path_to_env_var("NUKE_PATH", app_gizmo_folder)

# Nuke Studio 9 really doesn't like us running commands at startup, so don't.
if not (
nuke.env.get("NukeVersionMajor") == 9 and nuke.env.get("studio")
):
if not (nuke.env.get("NukeVersionMajor") == 9 and nuke.env.get("studio")):
self._run_commands_at_startup()

@property
Expand Down Expand Up @@ -511,10 +579,7 @@ def _run_commands_at_startup(self):
else:
if not setting_command_name:
# Run all commands of the given app instance.
for (
command_name,
command_function,
) in command_dict.items():
for (command_name, command_function) in command_dict.items():
self.logger.debug(
"%s startup running app '%s' command '%s'.",
self.name,
Expand Down Expand Up @@ -667,9 +732,7 @@ def _emit_log_message(self, handler, record):
#####################################################################################
# Panel Support

def show_panel(
self, panel_id, title, bundle, widget_class, *args, **kwargs
):
def show_panel(self, panel_id, title, bundle, widget_class, *args, **kwargs):
"""
Shows a panel in Nuke. If the panel already exists, the previous panel is swapped out
and replaced with a new one. In this case, the contents of the panel (e.g. the toolkit app)
Expand All @@ -692,9 +755,7 @@ def show_panel(
self.logger.info(
"Panels are not supported in Hiero. Launching as a dialog..."
)
return self.show_dialog(
title, bundle, widget_class, *args, **kwargs
)
return self.show_dialog(title, bundle, widget_class, *args, **kwargs)

# Note! Not using the import_module call as this confuses nuke's callback system
import tk_nuke_qt
Expand All @@ -704,9 +765,7 @@ def show_panel(
bundle, title, panel_id, widget_class, *args, **kwargs
)

self.logger.debug(
"Showing pane %s - %s from %s", panel_id, title, bundle.name
)
self.logger.debug("Showing pane %s - %s from %s", panel_id, title, bundle.name)

if hasattr(sgtk, "_callback_from_non_pane_menu"):
self.logger.debug("Looking for a pane.")
Expand All @@ -731,9 +790,7 @@ def show_panel(

existing_pane = None
for tab_name in built_in_tabs:
self.logger.debug(
"Parenting panel - looking for %s tab...", tab_name
)
self.logger.debug("Parenting panel - looking for %s tab...", tab_name)
existing_pane = nuke.getPaneFor(tab_name)
if existing_pane:
break
Expand Down Expand Up @@ -885,15 +942,14 @@ def _handle_studio_selection_change(self, event):

# If we've already seen this file selected before, or if it's
# not a .nk file, then we don't need to do anything.
if (
file_path not in self._processed_paths
and file_path.endswith(".nk")
if file_path not in self._processed_paths and file_path.endswith(
".nk"
):
self._processed_paths.append(file_path)
self._context_change_menu_rebuild = False
current_context = self.context
target_context = (
self._context_switcher.get_new_context(file_path)
target_context = self._context_switcher.get_new_context(
file_path
)

if target_context:
Expand All @@ -908,9 +964,7 @@ def _handle_studio_selection_change(self, event):

if env_name not in self._processed_environments:
self._processed_environments.append(env_name)
self._context_switcher.change_context(
target_context
)
self._context_switcher.change_context(target_context)
except Exception as e:
# If anything went wrong, we can just let the finally block
# run, which will put things back to the way they were.
Expand Down Expand Up @@ -958,9 +1012,7 @@ def _on_project_load_callback(self, event):
if new_context != self.context:
sgtk.platform.change_context(new_context)
except Exception:
self.logger.debug(
"Unable to determine context for file: %s", script_path
)
self.logger.debug("Unable to determine context for file: %s", script_path)

def _define_qt_base(self):
"""
Expand Down Expand Up @@ -1015,13 +1067,7 @@ def __setup_favorite_dirs(self):
)

# Ensure old favorites we used to use are removed.
supported_entity_types = [
"Shot",
"Sequence",
"Scene",
"Asset",
"Project",
]
supported_entity_types = ["Shot", "Sequence", "Scene", "Asset", "Project"]
for x in supported_entity_types:
nuke.removeFavoriteDir("Tank Current %s" % x)
nuke.removeFavoriteDir("Tank Current Work")
Expand Down Expand Up @@ -1057,9 +1103,7 @@ def __setup_favorite_dirs(self):
# Remove old directory
nuke.removeFavoriteDir(favorite["display_name"])
try:
template = self.get_template_by_name(
favorite["template_directory"]
)
template = self.get_template_by_name(favorite["template_directory"])
fields = self.context.as_template_fields(template)
path = template.apply_fields(fields)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion hooks/tk-multi-publish2/basic/nuke_publish_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def description(self):
contain simple html for formatting.
"""

loader_url = "https://support.shotgunsoftware.com/hc/en-us/articles/219033078"
loader_url = "https://developer.shotgridsoftware.com/a4c0a4f1/?title=Loader"

return """
Publishes the file to ShotGrid. A <b>Publish</b> entry will be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,6 @@ def _get_version_docs_action():
"action_open_url": {
"label": "Version Docs",
"tooltip": "Show docs for version formats",
"url": "https://support.shotgunsoftware.com/hc/en-us/articles/115000068574-User-Guide-WIP-#What%20happens%20when%20you%20publish",
"url": "https://help.autodesk.com/view/SGSUB/ENU/?guid=SG_Supervisor_Artist_sa_integrations_sa_integrations_user_guide_html",
}
}
15 changes: 12 additions & 3 deletions hooks/tk-multi-publish2/basic/nuke_update_flame_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,10 @@ def _update_flame_clip(self, item):
# </userData>
# </version>
date_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
formatted_name = _generate_flame_clip_name(item, render_path_fields,)
formatted_name = _generate_flame_clip_name(
item,
render_path_fields,
)

# <version type="version" uid="%s">
version_node = xml.createElement("version")
Expand Down Expand Up @@ -775,7 +778,10 @@ def _get_flame_frame_spec_from_path(path):
# We need to get all files that match the pattern from disk so that we
# can determine what the min and max frame number is. We replace the
# frame number or token with a * wildcard.
glob_path = "%s%s" % (re.sub(match.group(2), "*", root), ext,)
glob_path = "%s%s" % (
re.sub(match.group(2), "*", root),
ext,
)
files = glob.glob(glob_path)

# Our pattern from above matches against the file root, so we need
Expand Down Expand Up @@ -850,7 +856,10 @@ def _generate_flame_clip_name(item, publish_fields):
# foo1234 -> foo
# foo_1234 -> foo
default_name = re.sub(r"[._]*\d+$", "", default_name)
rp_name = publish_fields.get("name", default_name,)
rp_name = publish_fields.get(
"name",
default_name,
)
rp_channel = publish_fields.get("channel")

if rp_name and rp_channel:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def description(self):
contain simple html for formatting.
"""

loader_url = "https://support.shotgunsoftware.com/hc/en-us/articles/219033078"
loader_url = "https://developer.shotgridsoftware.com/a4c0a4f1/?title=Loader"

return """
Publishes the file to ShotGrid. A <b>Publish</b> entry will be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def _get_version_docs_action():
"action_open_url": {
"label": "Version Docs",
"tooltip": "Show docs for version formats",
"url": "https://support.shotgunsoftware.com/hc/en-us/articles/115000068574-User-Guide-WIP-#What%20happens%20when%20you%20publish",
"url": "https://help.autodesk.com/view/SGSUB/ENU/?guid=SG_Supervisor_Artist_sa_integrations_sa_integrations_user_guide_html",
}
}

Expand Down
2 changes: 1 addition & 1 deletion hooks/tk-multi-publish2/basic/submit_for_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def description(self):
contain simple html for formatting.
"""

review_url = "https://support.ShotGridsoftware.com/hc/en-us/articles/114094032014-The-review-workflow"
review_url = "https://help.autodesk.com/view/SGSUB/ENU/?guid=SG_Supervisor_Artist_sa_review_approval_sa_review_workflow_html"

return """<p>
Submits a movie file to ShotGrid for review. An entry will be
Expand Down
Binary file modified hooks/tk-multi-publish2/icons/flame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ configuration:

launch_builtin_plugins:
type: list
description: Comma-separated list of tk-maya plugins to load when launching Maya. Use
description: Comma-separated list of tk-nuke plugins to load when launching Nuke. Use
of this feature disables the classic mechanism for bootstrapping Toolkit
when Maya is launched.
when Nuke is launched.
allows_empty: True
default_value: []
values:
Expand Down Expand Up @@ -148,7 +148,7 @@ configuration:
type: int
description: "Specify the minimum Application major version that will prompt a warning if
it isn't yet fully supported and tested with Toolkit. To disable the warning
dialog for the version you are testing, it is recomended that you set this
dialog for the version you are testing, it is recommended that you set this
value to the current major version + 1."
default_value: 10

Expand Down
Loading

0 comments on commit cccda56

Please sign in to comment.