Script: Add script command list solver.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-10-24 15:13:35 +02:00
1 parent 4833685e2e
commit e556bcff54
2 files changed
+40

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
# ListSolver.py -- Pamhyr
# Copyright (C) 2023 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import os
import logging
from Scripts.AScript import AScript
logger = logging.getLogger()
class ScriptListSolver(AScript):
name = "ListSolver"
description = "List configured solver(s) for Pamhyr2"
def usage(self):
logger.info(f"Usage : {self._args[0]} {self._args[1]}")
def run(self):
for solver in self._conf.solvers:
print(f"{solver.name:<16} ({solver.type}): {solver.description}")
return 0
+2
View File
@@ -37,6 +37,7 @@ from Model.Study import Study
from Scripts.P3DST import Script3DST from Scripts.P3DST import Script3DST
from Scripts.Hello import ScriptHello from Scripts.Hello import ScriptHello
from Scripts.ListSolver import ScriptListSolver
from Scripts.Run import ScriptExport, ScriptRun from Scripts.Run import ScriptExport, ScriptRun
from init import legal_info, debug_info, setup_lang from init import legal_info, debug_info, setup_lang
@@ -45,6 +46,7 @@ logger = logging.getLogger()
scripts = { scripts = {
"hello": ScriptHello, "hello": ScriptHello,
"solvers": ScriptListSolver,
"export": ScriptExport, "export": ScriptExport,
"run": ScriptRun, "run": ScriptRun,
"3DST": Script3DST, "3DST": Script3DST,