-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_environment.py
More file actions
executable file
·136 lines (105 loc) · 3.74 KB
/
Copy pathsetup_environment.py
File metadata and controls
executable file
·136 lines (105 loc) · 3.74 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python3
"""
StackScout Environment Setup Assistant
This script helps users set up their environment variables for StackScout.
It provides guidance and generates configuration templates.
"""
import os
import sys
from pathlib import Path
def check_current_env():
"""Check if environment variables are already set."""
print("Checking current environment configuration...")
env_vars = ['SECRET_KEY', 'GEMINI_API_KEY', 'DATABASE_URL']
missing_vars = []
for var in env_vars:
if os.getenv(var):
print(f"✅ {var} is set")
else:
print(f"❌ {var} is not set")
missing_vars.append(var)
return missing_vars
def generate_env_template():
"""Generate a template for the .env file with instructions."""
template = """# StackScout Environment Configuration
# =============================================
# REQUIRED: Authentication Security
# Generate a strong secret key using: python generate_secret_key.py
SECRET_KEY=your_very_strong_secret_key_here
# REQUIRED: Google Gemini API
# Get your API key from: https://aistudio.google.com/
GEMINI_API_KEY=your_gemini_api_key_here
# Database Configuration (choose one option)
# Option 1: SQLite (default, recommended for development)
DATABASE_URL=sqlite:///stackscout.db
# Option 2: PostgreSQL (uncomment and configure for production)
# DB_HOST=localhost
# DB_NAME=job_scraper_db
# DB_USER=your_username
# DB_PASSWORD=your_secure_password
# DB_PORT=5432
# Optional: Email configuration (choose one option)
# Option 1: SendGrid (recommended)
# SENDGRID_API_KEY=your_sendgrid_api_key_here
# Option 2: SMTP (alternative)
# SMTP_SERVER=smtp.gmail.com
# SMTP_PORT=587
# SMTP_USERNAME=your_email@gmail.com
# SMTP_PASSWORD=your_app_password
# Optional: Debug settings
DEBUG=True
LOG_LEVEL=INFO
"""
return template
def main():
print("StackScout Environment Setup Assistant")
print("=" * 50)
# Check current environment
missing_vars = check_current_env()
if missing_vars:
print(f"\n⚠️ Missing required environment variables: {', '.join(missing_vars)}")
else:
print("\n✅ All required environment variables are set!")
return
print("\n" + "=" * 50)
print("SETUP INSTRUCTIONS:")
print("=" * 50)
# Generate and show env template
env_template = generate_env_template()
print("\nRecommended .env file content:")
print("-" * 30)
print(env_template)
# Check if .env file exists
env_file = Path('.env')
if env_file.exists():
print(f"\n📁 .env file already exists at: {env_file.absolute()}")
print("Please update it with the missing variables above.")
else:
print(f"\n📁 No .env file found. You can create one with the content above.")
print("\n" + "=" * 50)
print("QUICK SETUP COMMANDS:")
print("=" * 50)
env_example_file = Path('.env.example')
setup_commands = """
# Generate a strong SECRET_KEY:
python generate_secret_key.py
# Create .env file:"""
if env_example_file.exists():
setup_commands += """
cp .env.example .env"""
else:
setup_commands += """
echo '# StackScout Environment Configuration' > .env
echo 'SECRET_KEY=your_very_strong_secret_key_here' >> .env
echo 'GEMINI_API_KEY=your_gemini_api_key_here' >> .env
echo 'DATABASE_URL=sqlite:///stackscout.db' >> .env"""
setup_commands += """
# Set file permissions (recommended):
chmod 600 .env
# Test your configuration:
python -c "import os; print('✅ SECRET_KEY is properly configured' if os.getenv('SECRET_KEY') else '❌ SECRET_KEY is not set')"
"""
print(setup_commands)
print("\nFor detailed instructions, see ENVIRONMENT_SETUP_GUIDE.md")
if __name__ == "__main__":
main()