Publisher: Windows reduce command window pop-ups during Publishing (#4672)

* Avoid command pop-ups during publishing (tip by @iLLiCiTiT)

* No need to pass creationflags because it's already done in `run_subprocess`

* Hide command window for `shell=True` calls

* Update openpype/lib/execute.py

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>

---------

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
This commit is contained in:
Roy Nieterau 2023-03-22 12:13:21 +01:00 committed by GitHub
parent cc75f2ea21
commit 28b424bf2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 13 deletions

View file

@ -102,6 +102,10 @@ def run_subprocess(*args, **kwargs):
if (
platform.system().lower() == "windows"
and "creationflags" not in kwargs
# shell=True already tries to hide the console window
# and passing these creationflags then shows the window again
# so we avoid it for shell=True cases
and kwargs.get("shell") is not True
):
kwargs["creationflags"] = (
subprocess.CREATE_NEW_PROCESS_GROUP

View file

@ -224,18 +224,26 @@ def find_tool_in_custom_paths(paths, tool, validation_func=None):
def _check_args_returncode(args):
try:
# Python 2 compatibility where DEVNULL is not available
kwargs = {}
if platform.system().lower() == "windows":
kwargs["creationflags"] = (
subprocess.CREATE_NEW_PROCESS_GROUP
| getattr(subprocess, "DETACHED_PROCESS", 0)
| getattr(subprocess, "CREATE_NO_WINDOW", 0)
)
if hasattr(subprocess, "DEVNULL"):
proc = subprocess.Popen(
args,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
**kwargs
)
proc.wait()
else:
with open(os.devnull, "w") as devnull:
proc = subprocess.Popen(
args, stdout=devnull, stderr=devnull,
args, stdout=devnull, stderr=devnull, **kwargs
)
proc.wait()

View file

@ -16,9 +16,7 @@ from openpype.lib import (
get_transcode_temp_directory,
convert_input_paths_for_ffmpeg,
should_convert_for_ffmpeg,
CREATE_NO_WINDOW
should_convert_for_ffmpeg
)
from openpype.lib.profiles_filtering import filter_profiles
@ -338,8 +336,6 @@ class ExtractBurnin(publish.Extractor):
"logger": self.log,
"env": {}
}
if platform.system().lower() == "windows":
process_kwargs["creationflags"] = CREATE_NO_WINDOW
run_openpype_process(*args, **process_kwargs)
# Remove the temporary json

View file

@ -345,12 +345,6 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins):
"stderr": subprocess.PIPE,
"shell": True,
}
if platform.system().lower() == "windows":
kwargs["creationflags"] = (
subprocess.CREATE_NEW_PROCESS_GROUP
| getattr(subprocess, "DETACHED_PROCESS", 0)
| getattr(subprocess, "CREATE_NO_WINDOW", 0)
)
proc = subprocess.Popen(command, **kwargs)
_stdout, _stderr = proc.communicate()