fix: load env

This commit is contained in:
Gal 2025-02-22 11:25:55 +01:00
parent 00b048f177
commit 98d4db67ea
Signed by: gal
GPG Key ID: F035BC65003BC00B
1 changed files with 12 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import re
from typing import Set, Dict
import logging
from datetime import datetime
from dotenv import load_dotenv
# Configure logging
logging.basicConfig(
@ -21,11 +22,21 @@ logging.basicConfig(
def load_env_vars() -> tuple[Path, Path]:
"""Load environment variables and return source and destination directories."""
# Load .env file from the same directory as the script
script_dir = Path(__file__).parent.parent
env_path = script_dir / '.env'
if not env_path.exists():
logging.error(f".env file not found at {env_path}")
sys.exit(1)
load_dotenv(env_path)
source_dir = os.getenv('SOURCE_DIR')
dest_dir = os.getenv('DEST_DIR')
if not source_dir or not dest_dir:
logging.error("SOURCE_DIR and DEST_DIR must be set in environment variables")
logging.error("SOURCE_DIR and DEST_DIR must be set in .env file")
sys.exit(1)
# Expand environment variables like $HOME