-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_setup.py
More file actions
executable file
·157 lines (130 loc) · 5.12 KB
/
check_setup.py
File metadata and controls
executable file
·157 lines (130 loc) · 5.12 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env python3
"""
Configuration Checker
Verifies that all required files and dependencies are present
"""
import os
import sys
import json
def check_file_exists(filepath, description, required=True):
"""Check if a file exists"""
exists = os.path.exists(filepath)
status = "✓" if exists else ("✗" if required else "○")
req_text = "REQUIRED" if required else "optional"
print(f" [{status}] {description} ({filepath}) - {req_text}")
return exists
def check_json_file(filepath, description, required_keys=None):
"""Check if JSON file exists and has required keys"""
if not os.path.exists(filepath):
print(f" [✗] {description} - NOT FOUND")
return False
try:
with open(filepath, 'r') as f:
data = json.load(f)
if required_keys:
missing = [key for key in required_keys if key not in data]
if missing:
print(f" [✗] {description} - MISSING KEYS: {missing}")
return False
print(f" [✓] {description} - OK")
return True
except json.JSONDecodeError:
print(f" [✗] {description} - INVALID JSON")
return False
except Exception as e:
print(f" [✗] {description} - ERROR: {e}")
return False
def check_python_modules():
"""Check if required Python modules are installed"""
print("\n📦 Checking Python Dependencies...")
modules = [
('google.auth', 'google-auth'),
('google_auth_oauthlib', 'google-auth-oauthlib'),
('googleapiclient', 'google-api-python-client'),
('msal', 'msal'),
('requests', 'requests'),
]
all_installed = True
for module_name, package_name in modules:
try:
__import__(module_name)
print(f" [✓] {package_name}")
except ImportError:
print(f" [✗] {package_name} - NOT INSTALLED")
all_installed = False
return all_installed
def main():
print("="*60)
print("Email Manager - Configuration Checker")
print("="*60)
# Check Python version
print(f"\n🐍 Python Version: {sys.version}")
if sys.version_info < (3, 7):
print(" [✗] Python 3.7 or higher required!")
return False
else:
print(" [✓] Version OK")
# Check dependencies
deps_ok = check_python_modules()
# Check main script files
print("\n📄 Checking Script Files...")
scripts_ok = True
scripts_ok &= check_file_exists('email_manager.py', 'Main script')
scripts_ok &= check_file_exists('gmail_handler.py', 'Gmail handler')
scripts_ok &= check_file_exists('outlook_handler.py', 'Outlook handler')
scripts_ok &= check_file_exists('requirements.txt', 'Requirements file')
# Check credential files
print("\n🔑 Checking Credentials...")
print("\nGmail:")
gmail_creds = check_json_file('gmail_credentials.json', 'Gmail credentials')
gmail_token = check_file_exists('gmail_token.pickle', 'Gmail token (auto-generated)', required=False)
print("\nOutlook:")
outlook_creds = check_json_file(
'outlook_credentials.json',
'Outlook credentials',
required_keys=['client_id']
)
# Check templates
print("\n📋 Template Files (for reference):")
check_file_exists('outlook_credentials.json.template', 'Outlook template', required=False)
# Summary
print("\n" + "="*60)
print("📊 Summary")
print("="*60)
issues = []
if not deps_ok:
issues.append("Missing Python dependencies")
print("\n💡 To install dependencies, run:")
print(" pip install -r requirements.txt")
if not scripts_ok:
issues.append("Missing script files")
print("\n❌ Script files missing - please re-download the project")
if not gmail_creds:
issues.append("Gmail credentials not configured")
print("\n💡 To set up Gmail:")
print(" 1. Follow SETUP_GUIDE.md - Gmail section")
print(" 2. Download credentials from Google Cloud Console")
print(" 3. Save as 'gmail_credentials.json'")
if not outlook_creds:
issues.append("Outlook credentials not configured")
print("\n💡 To set up Outlook:")
print(" 1. Follow SETUP_GUIDE.md - Outlook section")
print(" 2. Copy outlook_credentials.json.template")
print(" 3. Add your Azure AD Client ID")
if not issues:
print("\n✅ All checks passed!")
print("\n🚀 Next steps:")
print(" 1. Run authentication setup:")
print(" python email_manager.py --setup-only")
print(" 2. Test in dry-run mode:")
print(" python email_manager.py")
print(" 3. Run live mode when ready:")
print(" python email_manager.py --live")
else:
print(f"\n⚠️ Found {len(issues)} issue(s):")
for i, issue in enumerate(issues, 1):
print(f" {i}. {issue}")
print("\n📖 See SETUP_GUIDE.md for detailed setup instructions")
print("\n" + "="*60)
if __name__ == '__main__':
main()