-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_env.py
More file actions
65 lines (57 loc) · 1.72 KB
/
test_env.py
File metadata and controls
65 lines (57 loc) · 1.72 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Test script to verify environment variables are loaded correctly.
"""
import os
from pathlib import Path
# Try to load dotenv
try:
from dotenv import load_dotenv
print("✓ python-dotenv is available")
except ImportError:
print("✗ python-dotenv is not available")
load_dotenv = None
# Load .env file
env_file = Path(__file__).parent / '.env'
print(f"Looking for .env file at: {env_file}")
print(f".env file exists: {env_file.exists()}")
if env_file.exists():
if load_dotenv:
load_dotenv(env_file)
print("✓ Loaded .env using python-dotenv")
else:
# Manual loading
with open(env_file, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
os.environ[key.strip()] = value.strip()
print("✓ Manually loaded .env file")
# Check environment variables
print("\nEnvironment Variables:")
required_vars = [
"SUPABASE_DB_USER",
"SUPABASE_DB_PASSWORD",
"SUPABASE_DB_HOST",
"SUPABASE_DB_PORT",
"SUPABASE_DB_NAME"
]
all_set = True
for var in required_vars:
value = os.getenv(var)
if value:
if 'PASSWORD' in var:
print(f" {var}: ****** (SET)")
else:
print(f" {var}: {value}")
else:
print(f" {var}: NOT SET")
all_set = False
print(f"\nAll required variables set: {'✓' if all_set else '✗'}")
if all_set:
print("\n✓ Environment is properly configured!")
print("You can now run: python main.py --setup-db")
else:
print("\n✗ Some environment variables are missing.")
print("Please check your .env file.")