diff --git a/src/Solver/ASolver.py b/src/Solver/ASolver.py index d438af053a23591b35696e4d29f348a5a9f5c3c9..300bb36c85ef59103c69a0618b2de7b08f5a8c68 100644 --- a/src/Solver/ASolver.py +++ b/src/Solver/ASolver.py @@ -176,17 +176,20 @@ class AbstractSolver(object): ) ) - def _format_command(self, cmd): + def _format_command(self, cmd, path = ""): """Format command line Args: cmd: The command line + path: Optional path string (replace @path in cmd) Returns: 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("@path", self._path_input) + cmd = cmd.replace("@path", path.replace(" ", "\ ")) cmd = cmd.replace("@input", self.input_param()) cmd = cmd.replace("@dir", self._process.workingDirectory()) @@ -195,13 +198,13 @@ class AbstractSolver(object): if cmd[0] == "\"": # Command line executable path is between " char cmd = cmd.split("\"") - exe = cmd[1] + exe = cmd[1].replace("\ ", " ") args = "\"".join(cmd[2:]).split(" ")[1:] else: # We suppose the command line executable path as no space char cmd = cmd.replace("\ ", "&_&").split(" ") - exe = cmd[0].replace("&_&", "\ ") - args = cmd[1:] + exe = cmd[0].replace("&_&", " ") + args = list(map(lambda s: s.replace("&_&", "\ "), cmd[1:])) logger.info(f"! {exe} {args}") return exe, args @@ -212,7 +215,7 @@ class AbstractSolver(object): return True 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): error = f"[ERROR] Path {exe} do not exists" @@ -231,7 +234,7 @@ class AbstractSolver(object): return True 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): error = f"[ERROR] Path {exe} do not exists" @@ -251,7 +254,7 @@ class AbstractSolver(object): return True 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): error = f"[ERROR] Path {exe} do not exists"