Skip to content

Commit

Permalink
starting code for ticket-68 + comment colorspace crash
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSouchet committed Oct 16, 2023
1 parent 3bdf4a6 commit 0b6d8c3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
6 changes: 6 additions & 0 deletions openpype/host/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ def get_current_context(self):
"task_name": self.get_current_task_name()
}

def update_current_context(self, data):
"""Test
"""
pass

def get_context_title(self):
"""Context title shown for UI purposes.
Expand Down
13 changes: 12 additions & 1 deletion openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2371,7 +2371,7 @@ def set_context_settings():
reset_frame_range()

# Set colorspace
set_colorspace()
#set_colorspace()


# Valid FPS
Expand Down Expand Up @@ -3259,10 +3259,14 @@ def set_colorspace():
ocio_v2_support = use_ocio_v2 = maya_version >= ocio_v2_maya_version
is_ocio_set = bool(os.environ.get("OCIO"))

log.warning("Try set_colorspace")

use_workfile_settings = imageio.get("workfile", {}).get("enabled")
if use_workfile_settings:
log.warning("INSIDE IF")
root_dict = imageio["workfile"]
else:
log.warning("INSIDE ELSE")
# TODO: deprecated code from 3.15.5 - remove
# Maya 2022+ introduces new OCIO v2 color management settings that
# can override the old color management preferences. OpenPype has
Expand All @@ -3278,15 +3282,18 @@ def set_colorspace():
)

if use_ocio_v2:
log.warning("INSIDE IF OCIO_V2")
root_dict = imageio["colorManagementPreference_v2"]
else:
log.warning("INSIDE ELSE OCIO_V2")
root_dict = imageio["colorManagementPreference"]

if not isinstance(root_dict, dict):
msg = "set_colorspace(): argument should be dictionary"
log.error(msg)
return

log.warning("AFTER")
# backward compatibility
# TODO: deprecated code from 3.15.5 - remove with deprecated code above
view_name = root_dict.get("viewTransform")
Expand All @@ -3297,6 +3304,8 @@ def set_colorspace():
if not root_dict:
return

log.warning("END___")

# set color spaces for rendering space and view transforms
def _colormanage(**kwargs):
"""Wrapper around `cmds.colorManagementPrefs`.
Expand All @@ -3317,6 +3326,7 @@ def _colormanage(**kwargs):
cmds.colorManagementPrefs(edit=True, ocioRulesEnabled=True)

if use_ocio_v2:
log.warning("OCIO V2")
log.info("Using Maya OCIO v2")
if not is_ocio_set:
# Set the Maya 2022+ default OCIO v2 config file path
Expand All @@ -3333,6 +3343,7 @@ def _colormanage(**kwargs):
_colormanage(viewName=view_name)
_colormanage(displayName=root_dict["displayName"])
else:
log.warning("LEGACY OCIO")
log.info("Using Maya OCIO v1 (legacy)")
if not is_ocio_set:
# Set the Maya default config file path
Expand Down
18 changes: 17 additions & 1 deletion openpype/hosts/maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from openpype.host import (
HostBase,
IWorkfileHost,
IPublishHost,
ILoadHost,
HostDirmap,
)
Expand Down Expand Up @@ -64,12 +65,13 @@
AVALON_CONTAINERS = ":AVALON_CONTAINERS"


class MayaHost(HostBase, IWorkfileHost, ILoadHost):
class MayaHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
name = "maya"

def __init__(self):
super(MayaHost, self).__init__()
self._op_events = {}
self._additional_context = {}

def install(self):
project_name = legacy_io.active_project()
Expand Down Expand Up @@ -128,6 +130,20 @@ def save_workfile(self, filepath=None):
def work_root(self, session):
return work_root(session)

def get_current_context(self):
# Specific to the current host keys:values
curr_context = self._additional_context
# Global host implementation keys:values
self.log.warning(curr_context)
self.log.warning("GETT ______________________________________________")
curr_context.update(super().get_current_context())

return curr_context

def update_current_context(self, data: dict):
self.log.warning("HERE ______________________________________________")
self._additional_context.update(data)

def get_current_workfile(self):
return current_file()

Expand Down
11 changes: 11 additions & 0 deletions openpype/modules/ftrack/launch_hooks/post_ftrack_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import ftrack_api
from openpype.settings import get_project_settings
from openpype.lib import PostLaunchHook
from openpype.pipeline import registered_host
from openpype.host import HostBase


class PostFtrackHook(PostLaunchHook):
Expand All @@ -13,6 +15,8 @@ def execute(self):
asset_name = self.data.get("asset_name")
task_name = self.data.get("task_name")

self.log.warning("___________________________________________________")
self.log.warning("POST ______________________________________________")
missing_context_keys = set()
if not project_name:
missing_context_keys.add("project_name")
Expand Down Expand Up @@ -46,6 +50,13 @@ def execute(self):
self.log.warning("Couldn't create Ftrack session")
return

host = registered_host()
self.log.warning(host)
if isinstance(host, HostBase):
self.log.warning("___________________________________________________")
self.log.warning("EDIT ______________________________________________")
return host.update_current_context({'test': 'toto'})

try:
entity = self.find_ftrack_task_entity(
session, project_name, asset_name, task_name
Expand Down
13 changes: 12 additions & 1 deletion openpype/tools/workfiles/files_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import qtpy
from qtpy import QtWidgets, QtCore

from openpype.host import IWorkfileHost
from openpype.host import IWorkfileHost, HostBase
from openpype.client import get_asset_by_id
from openpype.pipeline.workfile.lock_workfile import (
is_workfile_locked,
Expand All @@ -31,6 +31,8 @@
create_workdir_extra_folders,
)

from openpype.host import IPublishHost

from .model import (
WorkAreaFilesModel,
PublishFilesModel,
Expand Down Expand Up @@ -644,6 +646,15 @@ def _on_save_as_pressed(self):
self._save_as_with_dialog()

def _save_as_with_dialog(self):
host = self.host
if isinstance(host, HostBase):
log.warning("___________________________________________________")
log.warning("SAVE ______________________________________________")
log.warning(host.get_current_context())
log.warning(host)
else:
pass

work_filename = self.get_filename()
if not work_filename:
return None
Expand Down

0 comments on commit 0b6d8c3

Please sign in to comment.