added config file detection to migration env.py file
This commit is contained in:
parent
21b1c70989
commit
6c37589d1a
@ -1,3 +1,4 @@
|
||||
import os
|
||||
import tomllib
|
||||
from inspect import stack
|
||||
from logging.config import fileConfig
|
||||
@ -30,6 +31,20 @@ target_metadata = Base.metadata
|
||||
# ... etc.
|
||||
|
||||
def get_custom_url():
|
||||
# get the correct path
|
||||
paths: list[str] = [
|
||||
"./pillar_tool.toml",
|
||||
"/etc/pillar_tool/config.toml",
|
||||
]
|
||||
selected_path = None
|
||||
for path in paths:
|
||||
if os.path.exists(path):
|
||||
selected_path = path
|
||||
break
|
||||
|
||||
if selected_path is None:
|
||||
raise RuntimeError("No loadable config found!")
|
||||
|
||||
with open("./pillar_tool.toml", 'rb') as f:
|
||||
data = tomllib.load(f)
|
||||
user = data['db']['user']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user