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

config: Add default mage version into config.

Showing with 34 additions and 1 deletion
+34 -1
...@@ -168,12 +168,21 @@ class AbstractSolver(object): ...@@ -168,12 +168,21 @@ class AbstractSolver(object):
# Run # # Run #
####### #######
def _install_dir(self):
return os.path.abspath(
os.path.join(
os.path.dirname(__file__),
".."
)
)
def run_input_data_fomater(self): def run_input_data_fomater(self):
if self._cmd_input == "": if self._cmd_input == "":
self._run_next() self._run_next()
return True return True
cmd = self._cmd_input cmd = self._cmd_input
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_input) cmd = cmd.replace("@path", self._path_input)
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())
...@@ -196,6 +205,7 @@ class AbstractSolver(object): ...@@ -196,6 +205,7 @@ class AbstractSolver(object):
return True return True
cmd = self._cmd_solver cmd = self._cmd_solver
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_solver) cmd = cmd.replace("@path", self._path_solver)
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())
...@@ -219,6 +229,7 @@ class AbstractSolver(object): ...@@ -219,6 +229,7 @@ class AbstractSolver(object):
return True return True
cmd = self._cmd_output cmd = self._cmd_output
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_output) cmd = cmd.replace("@path", self._path_output)
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())
......
...@@ -34,7 +34,7 @@ logger = logging.getLogger() ...@@ -34,7 +34,7 @@ logger = logging.getLogger()
class Config(SQL): class Config(SQL):
def __init__(self): def __init__(self):
self._version = '0.0.1' self._version = '0.0.2'
self.filename = Config.filename() self.filename = Config.filename()
self.set_default_value() self.set_default_value()
...@@ -79,12 +79,34 @@ class Config(SQL): ...@@ -79,12 +79,34 @@ class Config(SQL):
self.commit() self.commit()
def _update(self): def _update(self):
version = self.execute(f"SELECT value FROM info WHERE key='version'")[0] version = self.execute(f"SELECT value FROM info WHERE key='version'")[0]
if version != self._version: if version != self._version:
logger.info(f"Configuration file update from {version} to {self._version}...") logger.info(f"Configuration file update from {version} to {self._version}...")
major, minor, release = version.strip().split(".")
if major == minor == "0":
if int(release) < 2:
# Add default solver
posix = os.name == 'posix'
self.execute(f"""
INSERT INTO solver VALUES (
'mage8',
'default-mage',
'Default PAMHYR mage 8 version',
'', '', '',
'',
'@install_dir/mage/mage{"" if posix else ".exe"} -fp=1 @input',
''
)
""")
self.commit()
def _load_solver(self): def _load_solver(self):
self._solvers = [] self._solvers = []
......
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