mirror of https://gitlab.com/pamhyr/pamhyr2
Solver: Fix command line parsing (again).
parent
dcc6e2df2d
commit
798d9198d6
|
|
@ -176,17 +176,20 @@ class AbstractSolver(object):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _format_command(self, cmd):
|
def _format_command(self, cmd, path = ""):
|
||||||
"""Format command line
|
"""Format command line
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
cmd: The command line
|
cmd: The command line
|
||||||
|
path: Optional path string (replace @path in cmd)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The executable and list of arguments
|
The executable and list of arguments
|
||||||
"""
|
"""
|
||||||
|
# HACK: Works in most case... Trust me i'm an engineer
|
||||||
|
|
||||||
cmd = cmd.replace("@install_dir", self._install_dir())
|
cmd = cmd.replace("@install_dir", self._install_dir())
|
||||||
cmd = cmd.replace("@path", self._path_input)
|
cmd = cmd.replace("@path", path.replace(" ", "\ "))
|
||||||
cmd = cmd.replace("@input", self.input_param())
|
cmd = cmd.replace("@input", self.input_param())
|
||||||
cmd = cmd.replace("@dir", self._process.workingDirectory())
|
cmd = cmd.replace("@dir", self._process.workingDirectory())
|
||||||
|
|
||||||
|
|
@ -195,13 +198,13 @@ class AbstractSolver(object):
|
||||||
if cmd[0] == "\"":
|
if cmd[0] == "\"":
|
||||||
# Command line executable path is between " char
|
# Command line executable path is between " char
|
||||||
cmd = cmd.split("\"")
|
cmd = cmd.split("\"")
|
||||||
exe = cmd[1]
|
exe = cmd[1].replace("\ ", " ")
|
||||||
args = "\"".join(cmd[2:]).split(" ")[1:]
|
args = "\"".join(cmd[2:]).split(" ")[1:]
|
||||||
else:
|
else:
|
||||||
# We suppose the command line executable path as no space char
|
# We suppose the command line executable path as no space char
|
||||||
cmd = cmd.replace("\ ", "&_&").split(" ")
|
cmd = cmd.replace("\ ", "&_&").split(" ")
|
||||||
exe = cmd[0].replace("&_&", "\ ")
|
exe = cmd[0].replace("&_&", " ")
|
||||||
args = cmd[1:]
|
args = list(map(lambda s: s.replace("&_&", "\ "), cmd[1:]))
|
||||||
|
|
||||||
logger.info(f"! {exe} {args}")
|
logger.info(f"! {exe} {args}")
|
||||||
return exe, args
|
return exe, args
|
||||||
|
|
@ -212,7 +215,7 @@ class AbstractSolver(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
cmd = self._cmd_input
|
cmd = self._cmd_input
|
||||||
exe, args = self._format_command(cmd)
|
exe, args = self._format_command(cmd, self._path_input)
|
||||||
|
|
||||||
if not os.path.exists(exe):
|
if not os.path.exists(exe):
|
||||||
error = f"[ERROR] Path {exe} do not exists"
|
error = f"[ERROR] Path {exe} do not exists"
|
||||||
|
|
@ -231,7 +234,7 @@ class AbstractSolver(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
cmd = self._cmd_solver
|
cmd = self._cmd_solver
|
||||||
exe, args = self._format_command(cmd)
|
exe, args = self._format_command(cmd, self._path_solver)
|
||||||
|
|
||||||
if not os.path.exists(exe):
|
if not os.path.exists(exe):
|
||||||
error = f"[ERROR] Path {exe} do not exists"
|
error = f"[ERROR] Path {exe} do not exists"
|
||||||
|
|
@ -251,7 +254,7 @@ class AbstractSolver(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
cmd = self._cmd_output
|
cmd = self._cmd_output
|
||||||
exe, args = self._format_command(cmd)
|
exe, args = self._format_command(cmd, self._path_output)
|
||||||
|
|
||||||
if not os.path.exists(exe):
|
if not os.path.exists(exe):
|
||||||
error = f"[ERROR] Path {exe} do not exists"
|
error = f"[ERROR] Path {exe} do not exists"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue