From 6f3b2c3b43c9da5d6635d83408c8aec19e293285 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 4 Feb 2022 15:36:56 +0100 Subject: [PATCH] OP-2414 - better capturing of stdout --- openpype/hooks/pre_non_python_host_launch.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openpype/hooks/pre_non_python_host_launch.py b/openpype/hooks/pre_non_python_host_launch.py index dd193616e6..f140ccab20 100644 --- a/openpype/hooks/pre_non_python_host_launch.py +++ b/openpype/hooks/pre_non_python_host_launch.py @@ -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 + })