diff --git a/openpype/hooks/pre_non_python_host_launch.py b/openpype/hooks/pre_non_python_host_launch.py index 946fad0546..043cb3c7f6 100644 --- a/openpype/hooks/pre_non_python_host_launch.py +++ b/openpype/hooks/pre_non_python_host_launch.py @@ -4,7 +4,7 @@ from openpype.lib import ( PreLaunchHook, get_openpype_execute_args ) -from openpype.lib.execute import get_non_python_host_kwargs +from openpype.lib.applications import get_non_python_host_kwargs from openpype import PACKAGE_DIR as OPENPYPE_DIR diff --git a/openpype/hosts/harmony/api/lib.py b/openpype/hosts/harmony/api/lib.py index d9222a8b60..d6fa1f30d8 100644 --- a/openpype/hosts/harmony/api/lib.py +++ b/openpype/hosts/harmony/api/lib.py @@ -16,14 +16,13 @@ import time from uuid import uuid4 from Qt import QtWidgets, QtCore, QtGui import collections -import platform from .server import Server from openpype.tools.stdout_broker.app import StdOutBroker from openpype.tools.utils import host_tools from openpype import style -from openpype.lib.execute import get_non_python_host_kwargs +from openpype.lib.applications import get_non_python_host_kwargs # Setup logging. log = logging.getLogger(__name__) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index 4227195235..7ff7c65777 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1676,3 +1676,38 @@ def should_workfile_tool_start( if output is None: return default_output return output + + +def get_non_python_host_kwargs(kwargs, allow_console=True): + """Explicit setting of kwargs for Popen for AE/PS/Harmony. + + Expected behavior + - openpype_console opens window with logs + - openpype_gui has stdout/stderr available for capturing + + Args: + kwargs (dict) or None + allow_console (bool): use False for inner Popen opening app itself or + it will open additional console (at least for Harmony) + """ + if kwargs is None: + kwargs = {} + + if platform.system().lower() != "windows": + return kwargs + + executable_path = os.environ.get("OPENPYPE_EXECUTABLE") + executable_filename = "" + if executable_path: + executable_filename = os.path.basename(executable_path) + if "openpype_gui" in executable_filename: + kwargs.update({ + "creationflags": subprocess.CREATE_NO_WINDOW, + "stdout": subprocess.DEVNULL, + "stderr": subprocess.DEVNULL + }) + elif allow_console: + kwargs.update({ + "creationflags": subprocess.CREATE_NEW_CONSOLE + }) + return kwargs diff --git a/openpype/lib/execute.py b/openpype/lib/execute.py index 3dc7f8631d..2e78df310c 100644 --- a/openpype/lib/execute.py +++ b/openpype/lib/execute.py @@ -274,36 +274,3 @@ def get_linux_launcher_args(*args): return launch_args - -def get_non_python_host_kwargs(kwargs, allow_console=True): - """Explicit setting of kwargs for Popen for AE/PS/Harmony. - - Expected behavior - - openpype_console opens window with logs - - openpype_gui has stdout/stderr available for capturing - - Args: - kwargs (dict) or None - allow_console (bool): use False for inner Popen opening app itself or - it will open additional console (at least for Harmony) - """ - if kwargs is None: - kwargs = {} - - if platform.system().lower() == "windows": - - executable_path = os.environ.get("OPENPYPE_EXECUTABLE") - executable_filename = "" - if executable_path: - executable_filename = os.path.basename(executable_path) - if "openpype_gui" in executable_filename: - kwargs.update({ - "creationflags": subprocess.CREATE_NO_WINDOW, - "stdout": subprocess.DEVNULL, - "stderr": subprocess.DEVNULL - }) - elif allow_console: - kwargs.update({ - "creationflags": subprocess.CREATE_NEW_CONSOLE - }) - return kwargs