mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
OP-2414 - updated logic for kwargs
Moved from execute to applications
This commit is contained in:
parent
e123c67c9d
commit
8bc173a9c2
4 changed files with 37 additions and 36 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue