fix env missing

main
MrWaradana 2 days ago
parent 022d2d0fc7
commit 63110dd412

@ -33,18 +33,15 @@ def get_env_tags(tag_list: List[str]) -> dict:
def get_config(): def get_config():
try: # Try to load from .env file in the project root
# Try to load from .env file in the project root project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) env_path = os.path.join(project_root, ".env")
env_path = os.path.join(project_root, ".env")
if os.path.exists(env_path):
if os.path.exists(env_path): config = Config(env_path)
config = Config(env_path) elif os.path.exists(".env"):
else: config = Config(".env")
# Fallback to default behavior (current working directory) else:
config = Config(".env")
except FileNotFoundError:
# If .env doesn't exist, use environment variables # If .env doesn't exist, use environment variables
config = Config(environ=os.environ) config = Config(environ=os.environ)

@ -13,8 +13,8 @@ def get_production_connection():
dbname="digital_twin", dbname="digital_twin",
user="digital_twin", user="digital_twin",
password="Pr0jec7@D!g!tTwiN", password="Pr0jec7@D!g!tTwiN",
host={COLLECTOR_HOSTNAME}, host=COLLECTOR_HOSTNAME,
port={COLLECTOR_PORT}, port=COLLECTOR_PORT,
) )
return production_connection return production_connection
except Exception as e: except Exception as e:
@ -36,15 +36,15 @@ def get_connection():
dbname="digital_twin", dbname="digital_twin",
user="postgres", user="postgres",
password="postgres", password="postgres",
host={DATABASE_HOSTNAME}, host=DATABASE_HOSTNAME,
port={DATABASE_PORT}, port=DATABASE_PORT,
) )
connection_wo_db = psycopg2.connect( connection_wo_db = psycopg2.connect(
dbname="digital_twin", dbname="digital_twin",
user="postgres", user="postgres",
password="postgres", password="postgres",
host={COLLECTOR_HOSTNAME}, host=COLLECTOR_HOSTNAME,
port={COLLECTOR_PORT}, port=COLLECTOR_PORT,
) )
return connection, connection_wo_db return connection, connection_wo_db
except Exception as e: except Exception as e:

Loading…
Cancel
Save