Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Hiero as a software option #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
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
30 changes: 20 additions & 10 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,13 @@ def post_app_init_studio(self, menu_name="ShotGrid"):
self._context_switcher = tk_nuke.PluginStudioContextSwitcher(self)
else:
hiero.core.events.registerInterest(
"kAfterNewProjectCreated", self.set_project_root,
"kAfterNewProjectCreated",
self.set_project_root,
)

hiero.core.events.registerInterest(
"kAfterProjectLoad", self._on_project_load_callback,
"kAfterProjectLoad",
self._on_project_load_callback,
)

self._context_switcher = tk_nuke.ClassicStudioContextSwitcher(self)
Expand All @@ -310,7 +312,8 @@ def post_app_init_studio(self, menu_name="ShotGrid"):
# processed. This ensure that all Nuke gizmos for the target environment
# will be available.
hiero.core.events.registerInterest(
"kSelectionChanged", self._handle_studio_selection_change,
"kSelectionChanged",
self._handle_studio_selection_change,
)

def log_user_attribute_metric(self, name, value):
Expand All @@ -337,11 +340,13 @@ def post_app_init_hiero(self, menu_name="ShotGrid"):
self._menu_generator.create_menu()

hiero.core.events.registerInterest(
"kAfterNewProjectCreated", self.set_project_root,
"kAfterNewProjectCreated",
self.set_project_root,
)

hiero.core.events.registerInterest(
"kAfterProjectLoad", self._on_project_load_callback,
"kAfterProjectLoad",
self._on_project_load_callback,
)

def post_app_init_nuke(self, menu_name="ShotGrid"):
Expand Down Expand Up @@ -377,7 +382,8 @@ def post_app_init_nuke(self, menu_name="ShotGrid"):
# the one it needs and then run the callback.
for (panel_id, panel_dict) in self.panels.items():
nukescripts.panels.registerPanel(
panel_id, panel_dict["callback"],
panel_id,
panel_dict["callback"],
)

# Iterate over all apps, if there is a gizmo folder, add it to nuke path.
Expand Down Expand Up @@ -555,15 +561,18 @@ def destroy_engine(self):
import hiero.core

hiero.core.events.unregisterInterest(
"kAfterNewProjectCreated", self.set_project_root,
"kAfterNewProjectCreated",
self.set_project_root,
)
hiero.core.events.unregisterInterest(
"kAfterProjectLoad", self._on_project_load_callback,
"kAfterProjectLoad",
self._on_project_load_callback,
)

if self.studio_enabled:
hiero.core.events.unregisterInterest(
"kSelectionChanged", self._handle_studio_selection_change,
"kSelectionChanged",
self._handle_studio_selection_change,
)

def post_context_change(self, old_context, new_context):
Expand Down Expand Up @@ -897,7 +906,8 @@ def _on_project_load_callback(self, event):
# Extract a new context based on the file and change to that
# context.
new_context = tk.context_from_path(
script_path, previous_context=self.context,
script_path,
previous_context=self.context,
)

if new_context != self.context:
Expand Down
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
17 changes: 12 additions & 5 deletions python/tk_nuke/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ def _get_context_from_script(self, script):
"""
tk = tank.tank_from_path(script)

context = tk.context_from_path(script, previous_context=self.engine.context,)
context = tk.context_from_path(
script,
previous_context=self.engine.context,
)

if context.project is None:
raise tank.TankError(
Expand Down Expand Up @@ -233,7 +236,8 @@ def _on_save_callback(self):
# Extract a new context based on the file and change to that
# context.
new_context = tk.context_from_path(
file_name, previous_context=self.context,
file_name,
previous_context=self.context,
)

self.change_context(new_context)
Expand Down Expand Up @@ -270,7 +274,8 @@ def _startup_node_callback(self):
return

new_ctx = tk.context_from_path(
file_name, previous_context=self.context,
file_name,
previous_context=self.context,
)

# Now change the context for the engine and apps.
Expand Down Expand Up @@ -346,7 +351,8 @@ def register_events(self, reregister=False):

# Event for context switching from Hiero to Nuke.
hiero.core.events.registerInterest(
hiero.core.events.EventType.kContextChanged, self._eventHandler,
hiero.core.events.EventType.kContextChanged,
self._eventHandler,
)

for func_desc in self._event_desc:
Expand Down Expand Up @@ -381,7 +387,8 @@ def unregister_events(self, only=None):
import hiero.core

hiero.core.events.unregisterInterest(
hiero.core.events.EventType.kContextChanged, self._eventHandler,
hiero.core.events.EventType.kContextChanged,
self._eventHandler,
)

func_descs = only or self._event_desc
Expand Down
41 changes: 30 additions & 11 deletions python/tk_nuke/menu_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ def __init__(self, engine, menu_name):

engine_root_dir = self.engine.disk_location
self._shotgun_logo = os.path.abspath(
os.path.join(engine_root_dir, "resources", "sg_logo_80px.png",),
os.path.join(
engine_root_dir,
"resources",
"sg_logo_80px.png",
),
)
self._shotgun_logo_blue = os.path.abspath(
os.path.join(engine_root_dir, "resources", "sg_logo_blue_32px.png",),
os.path.join(
engine_root_dir,
"resources",
"sg_logo_blue_32px.png",
),
)

@property
Expand Down Expand Up @@ -250,16 +258,19 @@ def _create_hiero_menu(self, add_commands=True, commands=None):

# Register for the interesting events.
hiero.core.events.registerInterest(
"kShowContextMenu/kBin", self.eventHandler,
"kShowContextMenu/kBin",
self.eventHandler,
)
hiero.core.events.registerInterest(
"kShowContextMenu/kTimeline", self.eventHandler,
"kShowContextMenu/kTimeline",
self.eventHandler,
)
# Note that the kViewer works differently than the other things
# (returns a hiero.ui.Viewer object: http://docs.thefoundry.co.uk/hiero/10/hieropythondevguide/api/api_ui.html#hiero.ui.Viewer)
# so we cannot support this easily using the same principles as for the other things.
hiero.core.events.registerInterest(
"kShowContextMenu/kSpreadsheet", self.eventHandler,
"kShowContextMenu/kSpreadsheet",
self.eventHandler,
)
self._menu_handle.addSeparator()

Expand Down Expand Up @@ -309,16 +320,19 @@ def destroy_menu(self):

# Register for the interesting events.
hiero.core.events.unregisterInterest(
"kShowContextMenu/kBin", self.eventHandler,
"kShowContextMenu/kBin",
self.eventHandler,
)
hiero.core.events.unregisterInterest(
"kShowContextMenu/kTimeline", self.eventHandler,
"kShowContextMenu/kTimeline",
self.eventHandler,
)
# Note that the kViewer works differently than the other things
# (returns a hiero.ui.Viewer object: http://docs.thefoundry.co.uk/hiero/10/hieropythondevguide/api/api_ui.html#hiero.ui.Viewer)
# so we cannot support this easily using the same principles as for the other things.
hiero.core.events.unregisterInterest(
"kShowContextMenu/kSpreadsheet", self.eventHandler,
"kShowContextMenu/kSpreadsheet",
self.eventHandler,
)

def eventHandler(self, event):
Expand Down Expand Up @@ -492,7 +506,9 @@ def create_disabled_menu(self, cmd_name, msg):

callback = lambda m=msg: nuke.message(m)
cmd = HieroAppCommand(
self.engine, cmd_name, dict(properties=dict(), callback=callback),
self.engine,
cmd_name,
dict(properties=dict(), callback=callback),
)
cmd.add_command_to_menu(self._menu_handle, icon=self._shotgun_logo_blue)

Expand Down Expand Up @@ -601,7 +617,8 @@ def create_menu(self, add_commands=True):
if cmd.type == "panel":
# First make sure the Shotgun pane menu exists.
pane_menu = nuke.menu("Pane").addMenu(
"ShotGrid", icon=self._shotgun_logo,
"ShotGrid",
icon=self._shotgun_logo,
)
# Now set up the callback.
cmd.add_command_to_pane_menu(pane_menu)
Expand All @@ -623,7 +640,9 @@ def create_disabled_menu(self, cmd_name, msg):

callback = lambda m=msg: nuke.message(m)
cmd = NukeAppCommand(
self.engine, cmd_name, dict(properties=dict(), callback=callback),
self.engine,
cmd_name,
dict(properties=dict(), callback=callback),
)
cmd.add_command_to_menu(self._menu_handle, icon=self._shotgun_logo_blue)

Expand Down
7 changes: 6 additions & 1 deletion python/tk_nuke_qt/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def __init__(self, bundle, dialog_name, panel_id, widget_class, *args, **kwargs)
# we cannot pass parameters to the constructor of our wrapper class
# directly, so instead pass them via a special class method
ToolkitWidgetWrapper.set_init_parameters(
widget_class, panel_id, bundle, self, args, kwargs,
widget_class,
panel_id,
bundle,
self,
args,
kwargs,
)

# Run parent constructor
Expand Down
1 change: 1 addition & 0 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class NukeLauncher(SoftwareLauncher):
"NukeAssist",
"NukeStudio",
"NukeX",
"Hiero",
]

# This dictionary defines a list of executable template strings for each
Expand Down
19 changes: 16 additions & 3 deletions tests/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ def test_nuke10(self):
Ensures we are returning the right variants for Nuke 10.
"""
self._test_nuke(
["Nuke 10.0v5", "NukeX 10.0v5", "NukeStudio 10.0v5", "NukeAssist 10.0v5"],
[
"Nuke 10.0v5",
"NukeX 10.0v5",
"NukeStudio 10.0v5",
"NukeAssist 10.0v5",
"Hiero 10.0v5",
],
"10.0v5",
)

Expand All @@ -217,7 +223,13 @@ def test_nuke9(self):
Ensures we are returning the right variants for Nuke 9.
"""
self._test_nuke(
["Nuke 9.0v8", "NukeX 9.0v8", "NukeStudio 9.0v8", "NukeAssist 9.0v8"],
[
"Nuke 9.0v8",
"NukeX 9.0v8",
"NukeStudio 9.0v8",
"NukeAssist 9.0v8",
"Hiero 9.0v8",
],
"9.0v8",
)

Expand Down Expand Up @@ -286,7 +298,8 @@ def _get_os_neutral_hierarchy(cls):
return cls._mac_mock_hierarchy

def _get_plugin_environment(
self, dcc_path,
self,
dcc_path,
):
"""
Returns the expected environment variables dictionary for a plugin.
Expand Down