From bb2a82d8e322c78eab8adccdd4687339f27f239c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 6 Apr 2021 10:12:11 +0200 Subject: [PATCH] arguments are not stored as list but as string as it is required for subprocess.Popen --- openpype/hooks/pre_with_windows_shell.py | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/openpype/hooks/pre_with_windows_shell.py b/openpype/hooks/pre_with_windows_shell.py index 5f0f03f13e..fbc9cafae0 100644 --- a/openpype/hooks/pre_with_windows_shell.py +++ b/openpype/hooks/pre_with_windows_shell.py @@ -1,4 +1,5 @@ import os +import subprocess from openpype.lib import PreLaunchHook @@ -15,10 +16,22 @@ class LaunchWithWindowsShell(PreLaunchHook): platforms = ["windows"] def execute(self): - # Get comspec which is cmd.exe in most cases. - comspec = os.environ.get("COMSPEC", "cmd.exe") - # Add comspec to arguments list and add "/k" - new_args = [comspec, "/c"] - new_args.extend(self.launch_context.launch_args) + new_args = [ + # Get comspec which is cmd.exe in most cases. + os.environ.get("COMSPEC", "cmd.exe"), + # NOTE change to "/k" if want to keep console opened + "/c", + # Convert arguments to command line arguments (as string) + "\"{}\"".format( + subprocess.list2cmdline(self.launch_context.launch_args) + ) + ] + # Convert list to string + # WARNING this only works if is used as string + args_string = " ".join(new_args) + self.log.info(( + "Modified launch arguments to be launched with shell \"{}\"." + ).format(args_string)) + # Replace launch args with new one - self.launch_context.launch_args = new_args + self.launch_context.launch_args = args_string