mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
fixed pype root handling during publshing of image sequences
This commit is contained in:
parent
8ed99e5759
commit
bcf32d8046
1 changed files with 25 additions and 12 deletions
|
|
@ -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__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue