Updated args to maketx

Better logging.
This commit is contained in:
Petr Kalis 2022-09-19 18:23:08 +02:00
parent d87b50f5d2
commit 56dcb25dc0

View file

@ -13,7 +13,7 @@ from maya import cmds # noqa
import pyblish.api
from openpype.lib import source_hash
from openpype.lib import source_hash, run_subprocess
from openpype.pipeline import legacy_io, publish
from openpype.hosts.maya.api import lib
@ -68,7 +68,7 @@ def find_paths_by_hash(texture_hash):
return legacy_io.distinct(key, {"type": "version"})
def maketx(source, destination, *args):
def maketx(source, destination, args, logger):
"""Make `.tx` using `maketx` with some default settings.
The settings are based on default as used in Arnold's
@ -79,7 +79,8 @@ def maketx(source, destination, *args):
Args:
source (str): Path to source file.
destination (str): Writing destination path.
*args: Additional arguments for `maketx`.
args: Additional arguments for `maketx`.
logger
Returns:
str: Output of `maketx` command.
@ -94,7 +95,7 @@ def maketx(source, destination, *args):
"OIIO tool not found in {}".format(maketx_path))
raise AssertionError("OIIO tool not found")
cmd = [
subprocess_args = [
maketx_path,
"-v", # verbose
"-u", # update mode
@ -103,27 +104,20 @@ def maketx(source, destination, *args):
"--checknan",
# use oiio-optimized settings for tile-size, planarconfig, metadata
"--oiio",
"--filter lanczos3",
escape_space(source)
"--filter", "lanczos3",
source
]
cmd.extend(args)
cmd.extend(["-o", escape_space(destination)])
subprocess_args.extend(args)
subprocess_args.extend(["-o", destination])
cmd = " ".join(cmd)
cmd = " ".join(subprocess_args)
logger.debug(cmd)
CREATE_NO_WINDOW = 0x08000000 # noqa
kwargs = dict(args=cmd, stderr=subprocess.STDOUT)
if sys.platform == "win32":
kwargs["creationflags"] = CREATE_NO_WINDOW
try:
out = subprocess.check_output(**kwargs)
except subprocess.CalledProcessError as exc:
print(exc)
import traceback
traceback.print_exc()
out = run_subprocess(subprocess_args)
except Exception:
logger.error("Maketx converion failed", exc_info=True)
raise
return out
@ -524,15 +518,17 @@ class ExtractLook(publish.Extractor):
if do_maketx and ext != ".tx":
# Produce .tx file in staging if source file is not .tx
converted = os.path.join(staging, "resources", fname + ".tx")
additional_args = [
"--sattrib",
"sourceHash",
texture_hash
]
if linearize:
self.log.info("tx: converting sRGB -> linear")
colorconvert = "--colorconvert sRGB linear"
else:
colorconvert = ""
additional_args.extend(["--colorconvert", "sRGB", "linear"])
config_path = get_ocio_config_path("nuke-default")
color_config = "--colorconfig {0}".format(config_path)
additional_args.extend(["--colorconfig", config_path])
# Ensure folder exists
if not os.path.exists(os.path.dirname(converted)):
os.makedirs(os.path.dirname(converted))
@ -541,12 +537,8 @@ class ExtractLook(publish.Extractor):
maketx(
filepath,
converted,
# Include `source-hash` as string metadata
"--sattrib",
"sourceHash",
escape_space(texture_hash),
colorconvert,
color_config
additional_args,
self.log
)
return converted, COPY, texture_hash