OP-2414 - better capturing of stdout

This commit is contained in:
Petr Kalis 2022-02-04 15:36:56 +01:00
parent 64c55c365a
commit 6f3b2c3b43

View file

@ -1,5 +1,6 @@
import os
import subprocess
import platform
from openpype.lib import (
PreLaunchHook,
@ -51,3 +52,15 @@ class NonPythonHostHook(PreLaunchHook):
if remainders:
self.launch_context.launch_args.extend(remainders)
if platform.system().lower() == "windows":
# expected behavior - openpype_console opens window with logs
# openpype_gui has stdout/stderr available for capturing
self.launch_context.kwargs.update({
"creationflags": subprocess.CREATE_NEW_CONSOLE
})
if "openpype_gui" in os.environ.get("OPENPYPE_EXECUTABLE"):
self.launch_context.kwargs.update({
"stdout": subprocess.DEVNULL,
"stderr": subprocess.DEVNULL
})