mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
arguments are not stored as list but as string as it is required for subprocess.Popen
This commit is contained in:
parent
fb4786e8aa
commit
bb2a82d8e3
1 changed files with 19 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
from openpype.lib import PreLaunchHook
|
from openpype.lib import PreLaunchHook
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -15,10 +16,22 @@ class LaunchWithWindowsShell(PreLaunchHook):
|
||||||
platforms = ["windows"]
|
platforms = ["windows"]
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
# Get comspec which is cmd.exe in most cases.
|
new_args = [
|
||||||
comspec = os.environ.get("COMSPEC", "cmd.exe")
|
# Get comspec which is cmd.exe in most cases.
|
||||||
# Add comspec to arguments list and add "/k"
|
os.environ.get("COMSPEC", "cmd.exe"),
|
||||||
new_args = [comspec, "/c"]
|
# NOTE change to "/k" if want to keep console opened
|
||||||
new_args.extend(self.launch_context.launch_args)
|
"/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
|
# Replace launch args with new one
|
||||||
self.launch_context.launch_args = new_args
|
self.launch_context.launch_args = args_string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue