config: Add default mage version into config.

results
Pierre-Antoine Rouby 2023-08-02 10:47:44 +02:00
parent 6500c889d9
commit c8a6d4ec74
2 changed files with 34 additions and 1 deletions

View File

@ -168,12 +168,21 @@ class AbstractSolver(object):
# Run #
#######
def _install_dir(self):
return os.path.abspath(
os.path.join(
os.path.dirname(__file__),
".."
)
)
def run_input_data_fomater(self):
if self._cmd_input == "":
self._run_next()
return True
cmd = self._cmd_input
cmd = cmd.replace("@install_dir", self._install_dir())
cmd = cmd.replace("@path", self._path_input)
cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory())
@ -196,6 +205,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())
@ -219,6 +229,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())

View File

@ -34,7 +34,7 @@ logger = logging.getLogger()
class Config(SQL):
def __init__(self):
self._version = '0.0.1'
self._version = '0.0.2'
self.filename = Config.filename()
self.set_default_value()
@ -79,12 +79,34 @@ class Config(SQL):
self.commit()
def _update(self):
version = self.execute(f"SELECT value FROM info WHERE key='version'")[0]
if version != 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):
self._solvers = []