mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merged in tokejepsen/pype/feature/unify_subprocess_calls (pull request #240)
Use lib subprocess. Approved-by: Milan Kolar <milan@orbi.tools>
This commit is contained in:
commit
c139c7f3e2
5 changed files with 48 additions and 45 deletions
|
|
@ -43,6 +43,9 @@ from .lib import (
|
|||
get_avalon_project_template
|
||||
)
|
||||
|
||||
# Special naming case for subprocess since its a built-in method.
|
||||
from .lib import _subprocess as subprocess
|
||||
|
||||
__all__ = [
|
||||
# plugin classes
|
||||
"Extractor",
|
||||
|
|
@ -54,12 +57,14 @@ __all__ = [
|
|||
# action
|
||||
"get_errored_instances_from_context",
|
||||
"RepairAction",
|
||||
"RepairContextAction",
|
||||
|
||||
"Logger",
|
||||
|
||||
"ValidationException",
|
||||
|
||||
# get contextual data
|
||||
"version_up",
|
||||
"get_handle_irregular",
|
||||
"get_project_data",
|
||||
"get_asset_data",
|
||||
|
|
@ -77,5 +82,6 @@ __all__ = [
|
|||
"set_project_code",
|
||||
"get_data_hierarchical_attr",
|
||||
"get_avalon_project_template",
|
||||
"subprocess"
|
||||
|
||||
]
|
||||
|
|
|
|||
19
pype/lib.py
19
pype/lib.py
|
|
@ -4,6 +4,7 @@ import logging
|
|||
import importlib
|
||||
import itertools
|
||||
import contextlib
|
||||
import subprocess
|
||||
|
||||
from .vendor import pather
|
||||
from .vendor.pather.error import ParseError
|
||||
|
|
@ -15,6 +16,24 @@ import avalon
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Special naming case for subprocess since its a built-in method.
|
||||
def _subprocess(args):
|
||||
"""Convenience method for getting output errors for subprocess."""
|
||||
|
||||
proc = subprocess.Popen(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdin=subprocess.PIPE,
|
||||
env=os.environ
|
||||
)
|
||||
|
||||
output = proc.communicate()[0]
|
||||
|
||||
if proc.returncode != 0:
|
||||
raise ValueError("\"{}\" was not successful: {}".format(args, output))
|
||||
|
||||
|
||||
def get_handle_irregular(asset):
|
||||
data = asset["data"]
|
||||
handle_start = data.get("handle_start", 0)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import pype.api
|
||||
import json
|
||||
|
||||
import pype.api
|
||||
import pyblish
|
||||
|
||||
|
||||
|
|
@ -92,31 +92,20 @@ class ExtractBurnin(pype.api.Extractor):
|
|||
|
||||
self.log.debug("__ EXE: {}".format(executable))
|
||||
|
||||
try:
|
||||
args = [executable, scriptpath, json_data]
|
||||
self.log.debug("Executing: {}".format(args))
|
||||
args = [executable, scriptpath, json_data]
|
||||
self.log.debug("Executing: {}".format(args))
|
||||
pype.api.subprocess(args)
|
||||
|
||||
# Explicitly passing the environment, because there are cases
|
||||
# where enviroment is not inherited.
|
||||
p = subprocess.Popen(args, env=os.environ)
|
||||
p.wait()
|
||||
repre_update = {
|
||||
"files": movieFileBurnin,
|
||||
"name": repre["name"],
|
||||
"tags": [x for x in repre["tags"] if x != "delete"]
|
||||
}
|
||||
instance.data["representations"][i].update(repre_update)
|
||||
|
||||
if not os.path.isfile(full_burnin_path):
|
||||
raise RuntimeError("File not existing: {}".format(full_burnin_path))
|
||||
except Exception as e:
|
||||
raise RuntimeError("Burnin script didn't work: `{}`".format(e))
|
||||
|
||||
if os.path.exists(full_burnin_path):
|
||||
repre_update = {
|
||||
"files": movieFileBurnin,
|
||||
"name": repre["name"],
|
||||
"tags": [x for x in repre["tags"] if x != "delete"]
|
||||
}
|
||||
instance.data["representations"][i].update(repre_update)
|
||||
|
||||
# removing the source mov file
|
||||
os.remove(full_movie_path)
|
||||
self.log.debug("Removed: `{}`".format(full_movie_path))
|
||||
# removing the source mov file
|
||||
os.remove(full_movie_path)
|
||||
self.log.debug("Removed: `{}`".format(full_movie_path))
|
||||
|
||||
# Remove any representations tagged for deletion.
|
||||
for repre in instance.data["representations"]:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
|
||||
import pyblish.api
|
||||
import subprocess
|
||||
from pype.vendor import clique
|
||||
import pype.api
|
||||
|
||||
|
||||
class ExtractJpegEXR(pyblish.api.InstancePlugin):
|
||||
|
|
@ -20,7 +21,6 @@ class ExtractJpegEXR(pyblish.api.InstancePlugin):
|
|||
order = pyblish.api.ExtractorOrder
|
||||
families = ["imagesequence", "render", "write", "source"]
|
||||
|
||||
|
||||
def process(self, instance):
|
||||
start = instance.data.get("startFrame")
|
||||
stagingdir = os.path.normpath(instance.data.get("stagingDir"))
|
||||
|
|
@ -59,8 +59,10 @@ class ExtractJpegEXR(pyblish.api.InstancePlugin):
|
|||
jpeg_items.append(full_output_path)
|
||||
|
||||
subprocess_jpeg = " ".join(jpeg_items)
|
||||
sub_proc = subprocess.Popen(subprocess_jpeg)
|
||||
sub_proc.wait()
|
||||
|
||||
# run subprocess
|
||||
self.log.debug("{}".format(subprocess_jpeg))
|
||||
pype.api.subprocess(subprocess_jpeg)
|
||||
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
|
||||
import pyblish.api
|
||||
import subprocess
|
||||
from pype.vendor import clique
|
||||
import pype.api
|
||||
from pypeapp import config
|
||||
|
||||
|
||||
|
|
@ -170,21 +171,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
|
||||
# run subprocess
|
||||
self.log.debug("{}".format(subprcs_cmd))
|
||||
sub_proc = subprocess.Popen(
|
||||
subprcs_cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdin=subprocess.PIPE,
|
||||
cwd=os.path.dirname(output_args[-1])
|
||||
)
|
||||
|
||||
output = sub_proc.communicate()[0]
|
||||
|
||||
if not os.path.isfile(full_output_path):
|
||||
raise ValueError(
|
||||
"Quicktime wasn't created succesfully: "
|
||||
"{}".format(output)
|
||||
)
|
||||
pype.api.subprocess(subprcs_cmd)
|
||||
|
||||
# create representation data
|
||||
repre_new.update({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue