Merge pull request #4618 from BigRoy/maya_fix_extract_look_arnold_load

This commit is contained in:
Milan Kolar 2023-03-17 23:01:19 +01:00 committed by GitHub
commit 18a4e9b2f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
"""Maya look extractor."""
import os
import sys
import json
import tempfile
import platform
import contextlib
import subprocess
from collections import OrderedDict
from maya import cmds # noqa
@ -23,6 +21,15 @@ COPY = 1
HARDLINK = 2
def _has_arnold():
"""Return whether the arnold package is available and can be imported."""
try:
import arnold # noqa: F401
return True
except (ImportError, ModuleNotFoundError):
return False
def escape_space(path):
"""Ensure path is enclosed by quotes to allow paths with spaces"""
return '"{}"'.format(path) if " " in path else path
@ -548,7 +555,7 @@ class ExtractLook(publish.Extractor):
color_space = cmds.getAttr(color_space_attr)
except ValueError:
# node doesn't have color space attribute
if cmds.loadPlugin("mtoa", quiet=True):
if _has_arnold():
img_info = image_info(filepath)
color_space = guess_colorspace(img_info)
else:
@ -560,7 +567,7 @@ class ExtractLook(publish.Extractor):
render_colorspace])
else:
if cmds.loadPlugin("mtoa", quiet=True):
if _has_arnold():
img_info = image_info(filepath)
color_space = guess_colorspace(img_info)
if color_space == "sRGB":