Merged in hotfix/deadline-rendering (pull request #391)

Hotfix/deadline rendering

Approved-by: Milan Kolar <milan@orbi.tools>
This commit is contained in:
Ondřej Samohel 2019-12-06 17:08:51 +00:00 committed by Milan Kolar
commit 2fe86bce27
2 changed files with 29 additions and 13 deletions

View file

@ -19,12 +19,15 @@ log = logging.getLogger(__name__)
def _subprocess(args):
"""Convenience method for getting output errors for subprocess."""
# make sure environment contains only strings
env = {k: str(v) for k, v in os.environ.items()}
proc = subprocess.Popen(
args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
env=os.environ
env=env
)
output = proc.communicate()[0]

View file

@ -4,6 +4,7 @@ import os
import logging
import subprocess
import platform
from shutil import which
handler = logging.basicConfig()
log = logging.getLogger("Publish Image Sequences")
@ -35,22 +36,32 @@ def __main__():
auto_pype_root = os.path.abspath(auto_pype_root + "../../../../..")
auto_pype_root = os.environ.get('PYPE_ROOT') or auto_pype_root
if kwargs.pype:
pype_root = kwargs.pype
else:
# if pype argument not specified, lets assume it is set in PATH
pype_root = ""
print("Set pype root to: {}".format(pype_root))
print("Paths: {}".format(kwargs.paths or [os.getcwd()]))
paths = kwargs.paths or [os.getcwd()]
pype_command = "pype.ps1"
if platform.system().lower() == "linux":
pype_command = "pype"
elif platform.system().lower() == "windows":
pype_command = "pype.bat"
if kwargs.pype:
pype_root = kwargs.pype
else:
# test if pype.bat / pype is in the PATH
# if it is, which() will return its path and we use that.
# if not, we use auto_pype_root path. Caveat of that one is
# that it can be UNC path and that will not work on windows.
pype_path = which(pype_command)
if pype_path:
pype_root = os.path.dirname(pype_path)
else:
pype_root = auto_pype_root
print("Set pype root to: {}".format(pype_root))
print("Paths: {}".format(kwargs.paths or [os.getcwd()]))
paths = kwargs.paths or [os.getcwd()]
args = [
os.path.join(pype_root, pype_command),
"publish",
@ -60,9 +71,11 @@ def __main__():
print("Pype command: {}".format(" ".join(args)))
# Forcing forwaring the environment because environment inheritance does
# not always work.
exit_code = subprocess.call(args, env=os.environ)
# Cast all values in environment to str to be safe
env = {k: str(v) for k, v in os.environ.items()}
exit_code = subprocess.call(args, env=env)
if exit_code != 0:
raise ValueError("Publishing failed.")
raise RuntimeError("Publishing failed.")
if __name__ == '__main__':