Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2013 Shotgun Software Inc.
#
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

"""
Expand All @@ -18,6 +18,7 @@
import tank
from tank import TankError


class NukeWriteNode(tank.platform.Application):

def init_app(self):
Expand Down Expand Up @@ -51,10 +52,10 @@ def destroy_app(self):
Called when the app is unloaded/destroyed
"""
self.log_debug("Destroying tk-nuke-writenode app")

# remove any callbacks that were registered by the handler:
self.__write_node_handler.remove_callbacks()

# clean up the nuke module:
if hasattr(nuke, "_shotgun_write_node_handler"):
del nuke._shotgun_write_node_handler
Expand All @@ -80,7 +81,7 @@ def post_context_change(self, old_context, new_context):
# these are triggered before the engine changes context, so we must manually call it here.
# this will force the path to reset and the profiles to be rebuilt.
self.__write_node_handler.setup_new_node(node)

def process_placeholder_nodes(self):
"""
Convert any placeholder nodes to TK Write Nodes
Expand All @@ -89,14 +90,14 @@ def process_placeholder_nodes(self):

# interface for other apps to query write node info:
#

# access general information:
def get_write_nodes(self):
"""
Return list of all write nodes
"""
return self.__write_node_handler.get_nodes()

def get_node_name(self, node):
"""
Return the name for the specified node
Expand All @@ -109,11 +110,11 @@ def get_node_profile_name(self, node):
is using
"""
return self.__write_node_handler.get_node_profile_name(node)

def get_node_tank_type(self, node):
"""
Return the tank type for the specified node

Note: Legacy version with old 'Tank Type' name - use
get_node_published_file_type instead!
"""
Expand All @@ -124,7 +125,7 @@ def get_node_published_file_type(self, node):
Return the published file type for the specified node
"""
return self.__write_node_handler.get_node_tank_type(node)

def is_node_render_path_locked(self, node):
"""
Determine if the render path for the specified node
Expand All @@ -134,77 +135,77 @@ def is_node_render_path_locked(self, node):
can happen if the file is moved on disk or if the template
is changed.
"""
return self.__write_node_handler.render_path_is_locked(node)
return self.__write_node_handler.render_path_is_locked(node)

# access full-res render information:
def get_node_render_path(self, node):
"""
Return the render path for the specified node
"""
return self.__write_node_handler.compute_render_path(node)
return self.__write_node_handler.compute_render_path(node)

def get_node_render_files(self, node):
"""
Return the list of rendered files for the node
"""
return self.__write_node_handler.get_files_on_disk(node)

def get_node_render_template(self, node):
"""
Return the render template for the specified node
"""
return self.__write_node_handler.get_render_template(node)

def get_node_publish_template(self, node):
"""
Return the publish template for the specified node
"""
return self.__write_node_handler.get_publish_template(node)

# access proxy-res render information:
def get_node_proxy_render_path(self, node):
"""
Return the render path for the specified node
"""
return self.__write_node_handler.compute_proxy_path(node)
return self.__write_node_handler.compute_proxy_path(node)

def get_node_proxy_render_files(self, node):
"""
Return the list of rendered files for the node
"""
return self.__write_node_handler.get_proxy_files_on_disk(node)

def get_node_proxy_render_template(self, node):
"""
Return the render template for the specified node
"""
return self.__write_node_handler.get_proxy_render_template(node)

def get_node_proxy_publish_template(self, node):
"""
Return the publish template for the specified node
"""
return self.__write_node_handler.get_proxy_publish_template(node)
return self.__write_node_handler.get_proxy_publish_template(node)

# useful utility functions:
def generate_node_thumbnail(self, node):
"""
Generate a thumnail for the specified node
"""
return self.__write_node_handler.generate_thumbnail(node)

def reset_node_render_path(self, node):
"""
Reset the render path of the specified node. This
will force the render path to be updated based on
the current script path and configuration.

Note, this should really never be needed now that the
path is reset automatically when the user changes something.
"""
self.__write_node_handler.reset_render_path(node)

def convert_to_write_nodes(self, show_warning=False):
def convert_to_write_nodes(self, nodes=list(), show_warning=False):
"""
Convert all Shotgun write nodes found in the current Script to regular
Nuke Write nodes. Additional toolkit information will be stored on
Expand All @@ -223,8 +224,8 @@ def convert_to_write_nodes(self, show_warning=False):
# defer importing the QT module so the app doesn't require QT unless running this method with the warning.
from sgtk.platform.qt import QtGui
res = QtGui.QMessageBox.question(None,
"Convert All SG Write Nodes?",
"This will convert all Shotgun write nodes to standard write nodes."
"Convert SG Write Nodes?",
"This will convert Shotgun write nodes to standard write nodes."
"\nOK to proceed?",
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)

Expand All @@ -233,9 +234,9 @@ def convert_to_write_nodes(self, show_warning=False):
continue_with_convert = False

if continue_with_convert:
self.__write_node_handler.convert_sg_to_nuke_write_nodes()
self.__write_node_handler.convert_sg_to_nuke_write_nodes(nodes)

def convert_from_write_nodes(self, show_warning=False):
def convert_from_write_nodes(self, nodes=list(), show_warning=False):
"""
Convert all regular Nuke Write nodes that have previously been converted
from Shotgun Write nodes, back into Shotgun Write nodes.
Expand All @@ -251,19 +252,18 @@ def convert_from_write_nodes(self, show_warning=False):
# defer importing the QT module so the app doesn't require QT unless running this method with the warning.
from sgtk.platform.qt import QtGui
res = QtGui.QMessageBox.question(None,
"Convert All Write Nodes?",
"This will convert any Shotgun Write Nodes that have been converted "
"Convert Write Nodes?",
"This will convert Shotgun Write Nodes that have been converted "
"into standard write nodes back to their original form."
"\nOK to proceed?",
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)


if res != QtGui.QMessageBox.Yes:
# User chose to abort the operation, we should not convert the write nodes
continue_with_convert = False

if continue_with_convert:
self.__write_node_handler.convert_nuke_to_sg_write_nodes()
self.__write_node_handler.convert_nuke_to_sg_write_nodes(nodes)

def create_new_write_node(self, profile_name):
"""
Expand All @@ -284,10 +284,10 @@ def __add_write_node_commands(self, context=None):

for profile_name in self.__write_node_handler.profile_names:
# add to toolbar menu
cb_fn = lambda pn=profile_name: self.__write_node_handler.create_new_node(pn)
def cb_fn(pn=profile_name): return self.__write_node_handler.create_new_node(pn)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple statements on one line (def)

self.engine.register_command(
"%s [Shotgun]" % profile_name,
cb_fn,
cb_fn,
dict(
type="node",
icon=write_node_icon,
Expand All @@ -307,8 +307,8 @@ def __add_write_node_commands(self, context=None):
if not promoted_knob_write_nodes:
# no presets use promoted knobs so we are OK to register the menus.

convert_to_write_nodes_action = lambda :self.convert_to_write_nodes(show_warning=True)
convert_from_write_nodes_action = lambda: self.convert_from_write_nodes(show_warning=True)
def convert_to_write_nodes_action(): return self.convert_to_write_nodes(show_warning=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple statements on one line (def)

def convert_from_write_nodes_action(): return self.convert_from_write_nodes(show_warning=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 1 blank line before a nested definition, found 0
multiple statements on one line (def)


self.engine.register_command(
"Convert SG Write Nodes to Write Nodes...",
Expand Down
Loading