mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-29 19:10:42 +01:00
Solver: Fix command line parsing.
This commit is contained in:
1 parent
475c9fb23c
commit
cecbb68177
1 file changed
+20
-42
+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"
|
||||
|
||||
Reference in new issue
Block a user