From 1914a0dd0212473beba1ee7e4715c3d7441be057 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 14 Mar 2023 10:07:00 +0100 Subject: [PATCH 1/3] Remove unused imports --- openpype/hosts/maya/plugins/publish/extract_look.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index efeddcfbe4..bfa26d158f 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -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 From e250d8935f45490ee991b9ac11bc8ec758f3c32d Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 14 Mar 2023 10:14:09 +0100 Subject: [PATCH 2/3] Don't require to `arnold` plug-in to be available, don't force load it if we don't need it. --- openpype/hosts/maya/plugins/publish/extract_look.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index bfa26d158f..1893155291 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -21,6 +21,15 @@ COPY = 1 HARDLINK = 2 +def _has_arnold(): + """Return whether the arnold package is available and can be imported.""" + try: + import arnold + 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 @@ -546,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: @@ -558,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": From f0a76b5cc56b9b6577f768f1390d06468a6cec4e Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Tue, 14 Mar 2023 11:01:45 +0100 Subject: [PATCH 3/3] Shush hound --- openpype/hosts/maya/plugins/publish/extract_look.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_look.py b/openpype/hosts/maya/plugins/publish/extract_look.py index 1893155291..bc506b7feb 100644 --- a/openpype/hosts/maya/plugins/publish/extract_look.py +++ b/openpype/hosts/maya/plugins/publish/extract_look.py @@ -24,7 +24,7 @@ HARDLINK = 2 def _has_arnold(): """Return whether the arnold package is available and can be imported.""" try: - import arnold + import arnold # noqa: F401 return True except (ImportError, ModuleNotFoundError): return False