Commit cecbb681 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Solver: Fix command line parsing.

Showing with 20 additions and 42 deletions
+20 -42
......@@ -176,12 +176,15 @@ class AbstractSolver(object):
)
)
def run_input_data_fomater(self):
if self._cmd_input == "":
self._run_next()
return True
def _format_command(self, cmd):
"""Format command line
cmd = self._cmd_input
Args:
cmd: The command line
Returns:
The executable and list of arguments
"""
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_input)
cmd = cmd.replace("@input", self.input_param())
......@@ -193,7 +196,7 @@ class AbstractSolver(object):
# Command line executable path is between " char
cmd = cmd.split("\"")
exe = cmd[1]
args = "\"".join(cmd[3:]).split(" ")
args = "\"".join(cmd[2:]).split(" ")[1:]
else:
# We suppose the command line executable path as no space char
cmd = cmd.replace("\ ", "&_&").split(" ")
......@@ -201,6 +204,15 @@ class AbstractSolver(object):
args = cmd[1:]
logger.info(f"! {exe} {args}")
return exe, args
def run_input_data_fomater(self):
if self._cmd_input == "":
self._run_next()
return True
cmd = self._cmd_input
exe, args = self._format_command(cmd)
if not os.path.exists(exe):
error = f"[ERROR] Path {exe} do not exists"
......@@ -219,25 +231,7 @@ class AbstractSolver(object):
return True
cmd = self._cmd_solver
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_solver)
cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory())
logger.info(f"! {cmd}")
if cmd[0] == "\"":
# Command line executable path is between " char
cmd = cmd.split("\"")
exe = cmd[1]
args = "\"".join(cmd[3:]).split(" ")
else:
# We suppose the command line executable path as no space char
cmd = cmd.replace("\ ", "&_&").split(" ")
exe = cmd[0].replace("&_&", "\ ")
args = cmd[1:]
logger.info(f"! {exe} {args}")
exe, args = self._format_command(cmd)
if not os.path.exists(exe):
error = f"[ERROR] Path {exe} do not exists"
......@@ -257,23 +251,7 @@ class AbstractSolver(object):
return True
cmd = self._cmd_output
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_output)
cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory())
logger.debug(f"! {cmd}")
if cmd[0] == "\"":
# Command line executable path is between " char
cmd = cmd.split("\"")
exe = cmd[1]
args = "\"".join(cmd[3:]).split(" ")
else:
# We suppose the command line executable path as no space char
cmd = cmd.replace("\ ", "&_&").split(" ")
exe = cmd[0].replace("&_&", "\ ")
args = cmd[1:]
exe, args = self._format_command(cmd)
if not os.path.exists(exe):
error = f"[ERROR] Path {exe} do not exists"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment