improve config filename error handling

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-03-02 01:01:52 +01:00
parent 4a4f02427c
commit 84e5482a6d
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 10 additions and 1 deletions

View File

@ -10,7 +10,16 @@ def study():
print("You need to pass a configuration file in parameter")
exit(1)
try:
config = importlib.import_module(sys.argv[1])
except ModuleNotFoundError as e:
try:
config = importlib.import_module(str(sys.argv[1]).replace(".py", ""))
except ModuleNotFoundError as e:
print(e)
print("You need to pass a configuration file in parameter")
exit(1)
shape = Shape(0, 0, 0, 0, 0, 0)
sim = Simulator(shape, config)
sim.initLogger()