diff --git a/openpype/pipeline/colorspace.py b/openpype/pipeline/colorspace.py index 9f720f6ae95..2d1837e8ead 100644 --- a/openpype/pipeline/colorspace.py +++ b/openpype/pipeline/colorspace.py @@ -463,9 +463,13 @@ def compatibility_check(): try: import PyOpenColorIO # noqa: F401 + config = PyOpenColorIO.GetCurrentConfig() + config.getDisplayViewColorSpaceName("sRGB", "sRGB") CachedData.has_compatible_ocio_package = True except ImportError: CachedData.has_compatible_ocio_package = False + except AttributeError: + CachedData.has_compatible_ocio_package = False # compatible return CachedData.has_compatible_ocio_package diff --git a/openpype/scripts/ocio_wrapper.py b/openpype/scripts/ocio_wrapper.py index 45227c11f8b..fe3fbb5d920 100644 --- a/openpype/scripts/ocio_wrapper.py +++ b/openpype/scripts/ocio_wrapper.py @@ -18,10 +18,9 @@ - returning all available viewers found in input config path. """ - +import os import click import json -from pathlib import Path import PyOpenColorIO as ocio @@ -76,14 +75,12 @@ def get_colorspace(in_path, out_path): > pyton.exe ./ocio_wrapper.py config get_colorspace --in_path= --out_path= """ - json_path = Path(out_path) - out_data = _get_colorspace_data(in_path) - with open(json_path, "w") as f_: + with open(out_path, "w") as f_: json.dump(out_data, f_) - print("Colorspace data are saved to '{}'".format(json_path)) + print("Colorspace data are saved to '{}'".format(out_path)) def _get_colorspace_data(config_path): @@ -98,13 +95,11 @@ def _get_colorspace_data(config_path): Returns: dict: aggregated available colorspaces """ - config_path = Path(config_path) - - if not config_path.is_file(): + if not os.path.isfile(config_path): raise IOError( "Input path `{}` should be `config.ocio` file".format(config_path)) - config = ocio.Config().CreateFromFile(str(config_path)) + config = ocio.Config().CreateFromFile(config_path) colorspace_data = { "roles": {}, @@ -173,14 +168,12 @@ def get_views(in_path, out_path): > pyton.exe ./ocio_wrapper.py config get_views \ --in_path= --out_path= """ - json_path = Path(out_path) - out_data = _get_views_data(in_path) - with open(json_path, "w") as f_: + with open(out_path, "w") as f_: json.dump(out_data, f_) - print("Viewer data are saved to '{}'".format(json_path)) + print("Viewer data are saved to '{}'".format(out_path)) def _get_views_data(config_path): @@ -195,12 +188,10 @@ def _get_views_data(config_path): Returns: dict: aggregated available viewers """ - config_path = Path(config_path) - - if not config_path.is_file(): + if not os.path.isfile(config_path): raise IOError("Input path should be `config.ocio` file") - config = ocio.Config().CreateFromFile(str(config_path)) + config = ocio.Config().CreateFromFile(config_path) data_ = {} for display in config.getDisplays(): @@ -247,14 +238,12 @@ def get_version(config_path, out_path): > pyton.exe ./ocio_wrapper.py config get_version \ --config_path= --out_path= """ - json_path = Path(out_path) - out_data = _get_version_data(config_path) - with open(json_path, "w") as f_: + with open(out_path, "w") as f_: json.dump(out_data, f_) - print("Config version data are saved to '{}'".format(json_path)) + print("Config version data are saved to '{}'".format(out_path)) def _get_version_data(config_path): @@ -269,12 +258,10 @@ def _get_version_data(config_path): Returns: dict: minor and major keys with values """ - config_path = Path(config_path) - - if not config_path.is_file(): + if not os.path.isfile(config_path): raise IOError("Input path should be `config.ocio` file") - config = ocio.Config().CreateFromFile(str(config_path)) + config = ocio.Config().CreateFromFile(config_path) return { "major": config.getMajorVersion(), @@ -317,15 +304,13 @@ def get_config_file_rules_colorspace_from_filepath( colorspace get_config_file_rules_colorspace_from_filepath \ --config_path= --filepath= --out_path= """ - json_path = Path(out_path) - colorspace = _get_config_file_rules_colorspace_from_filepath( config_path, filepath) - with open(json_path, "w") as f_: + with open(out_path, "w") as f_: json.dump(colorspace, f_) - print("Colorspace name is saved to '{}'".format(json_path)) + print("Colorspace name is saved to '{}'".format(out_path)) def _get_config_file_rules_colorspace_from_filepath(config_path, filepath): @@ -341,16 +326,14 @@ def _get_config_file_rules_colorspace_from_filepath(config_path, filepath): Returns: dict: aggregated available colorspaces """ - config_path = Path(config_path) - - if not config_path.is_file(): + if not os.path.isfile(config_path): raise IOError( "Input path `{}` should be `config.ocio` file".format(config_path)) - config = ocio.Config().CreateFromFile(str(config_path)) + config = ocio.Config().CreateFromFile(config_path) # TODO: use `parseColorSpaceFromString` instead if ocio v1 - colorspace = config.getColorSpaceFromFilepath(str(filepath)) + colorspace = config.getColorSpaceFromFilepath(filepath) return colorspace @@ -370,13 +353,10 @@ def _get_display_view_colorspace_name(config_path, display, view): Returns: view color space name (str) e.g. "Output - sRGB" """ - - config_path = Path(config_path) - - if not config_path.is_file(): + if not os.path.isfile(config_path): raise IOError("Input path should be `config.ocio` file") - config = ocio.Config.CreateFromFile(str(config_path)) + config = ocio.Config.CreateFromFile(config_path) colorspace = config.getDisplayViewColorSpaceName(display, view) return colorspace