Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1684 from pypeclub/bugfix/stdout_stderr_applicati…
Browse files Browse the repository at this point in the history
…on_launch

Application launch stdout/stderr in GUI build
  • Loading branch information
iLLiCiTiT authored Jul 26, 2021
2 parents b6d08ef + a0beedd commit f320750
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 45 deletions.
28 changes: 28 additions & 0 deletions openpype/hooks/pre_foundry_apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import subprocess
from openpype.lib import PreLaunchHook


class LaunchFoundryAppsWindows(PreLaunchHook):
"""Foundry applications have specific way how to launch them.
Nuke is executed "like" python process so it is required to pass
`CREATE_NEW_CONSOLE` flag on windows to trigger creation of new console.
At the same time the newly created console won't create it's own stdout
and stderr handlers so they should not be redirected to DEVNULL.
"""

# Should be as last hook because must change launch arguments to string
order = 1000
app_groups = ["nuke", "nukex", "hiero", "nukestudio"]
platforms = ["windows"]

def execute(self):
# Change `creationflags` to CREATE_NEW_CONSOLE
# - on Windows will nuke create new window using it's console
# Set `stdout` and `stderr` to None so new created console does not
# have redirected output to DEVNULL in build
self.launch_context.kwargs.update({
"creationflags": subprocess.CREATE_NEW_CONSOLE,
"stdout": None,
"stderr": None
})
4 changes: 3 additions & 1 deletion openpype/hooks/pre_non_python_host_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ def execute(self):
if remainders:
self.launch_context.launch_args.extend(remainders)

# This must be set otherwise it wouldn't be possible to catch output
# when build OpenPype is used.
self.launch_context.kwargs["stdout"] = subprocess.DEVNULL
self.launch_context.kwargs["stderr"] = subprocess.STDOUT
self.launch_context.kwargs["stderr"] = subprocess.DEVNULL
44 changes: 0 additions & 44 deletions openpype/hooks/pre_with_windows_shell.py

This file was deleted.

5 changes: 5 additions & 0 deletions openpype/lib/applications.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import re
import copy
import json
Expand Down Expand Up @@ -708,6 +709,10 @@ def __init__(self, application, executable, **data):
)
self.kwargs["creationflags"] = flags

if not sys.stdout:
self.kwargs["stdout"] = subprocess.DEVNULL
self.kwargs["stderr"] = subprocess.DEVNULL

self.prelaunch_hooks = None
self.postlaunch_hooks = None

Expand Down

0 comments on commit f320750

Please sign in to comment.