LaunchSettingsBase: Use shlex.split validate the pre-launch command
This commit is contained in:
parent
259bc98eb9
commit
0ac4cf5a7c
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import platform
|
||||
import shlex
|
||||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
|
@ -76,7 +77,7 @@ class PreLaunchThread(QRunnable):
|
|||
proc = get_configured_process()
|
||||
proc.setProcessEnvironment(launch_args.environment)
|
||||
self.signals.started_pre_launch_command.emit()
|
||||
pre_launch_command = launch_args.pre_launch_command.split()
|
||||
pre_launch_command = shlex.split(launch_args.pre_launch_command)
|
||||
# self.logger.debug("Executing prelaunch command %s, %s", pre_launch_command[0], pre_launch_command[1:])
|
||||
proc.start(pre_launch_command[0], pre_launch_command[1:])
|
||||
if launch_args.pre_launch_wait:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
from typing import Tuple, Type, TypeVar
|
||||
|
||||
|
@ -73,7 +74,11 @@ class LaunchSettingsBase(QGroupBox):
|
|||
def __prelaunch_edit_callback(text: str) -> Tuple[bool, str, int]:
|
||||
if not text.strip():
|
||||
return True, text, IndicatorReasonsCommon.VALID
|
||||
if not os.path.isfile(text.split()[0]) and not shutil.which(text.split()[0]):
|
||||
try:
|
||||
command = shlex.split(text)[0]
|
||||
except ValueError:
|
||||
return False, text, IndicatorReasonsCommon.WRONG_FORMAT
|
||||
if not os.path.isfile(command) and not shutil.which(command):
|
||||
return False, text, IndicatorReasonsCommon.FILE_NOT_EXISTS
|
||||
else:
|
||||
return True, text, IndicatorReasonsCommon.VALID
|
||||
|
|
Loading…
Reference in a new issue