forked from OpenLWR/OpenLWR-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
29 lines (21 loc) · 854 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import config
import shutil
import json
config = None
if config == None:
try:
if not os.path.isfile("config.json"):
print("Config file not found, creating")
shutil.copy("config.example.json", "config.json")
with open("config.json") as config_file:
config = json.load(config_file)
if not os.path.isdir("simulation/models/%s" % config["model"]):
print("The configured model directory does not exist.")
exit()
if not os.path.isfile("simulation/models/%s/model.py" % config["model"]):
print("The configured model has a directory but no model.py. Did you misspell model.py?")
exit()
print("The config initialized sucessfully.")
except Exception as e:
print(f"Failed to load config file: {e}")