-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_credentials.py
More file actions
54 lines (42 loc) · 1.73 KB
/
Copy pathsetup_credentials.py
File metadata and controls
54 lines (42 loc) · 1.73 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
#!/usr/bin/env python3
"""
Helper script to transfer API credentials from main_enhanced.py to GUI settings.
"""
import json
import keyring
from pathlib import Path
def setup_credentials():
"""Transfer credentials from main_enhanced.py to GUI settings."""
print("🔑 ChiCom Crawl - Credential Setup")
print("=" * 40)
# Your existing credentials from main_enhanced.py
API_KEY = "AIzaSyC2odz9ciiZZ2sfuxbrKQXvwBlkLdLm7FQ"
SEARCH_ENGINE_ID = "738360188e72d4602"
print(f"📋 Found credentials:")
print(f" API Key: {API_KEY[:20]}...")
print(f" Search Engine ID: {SEARCH_ENGINE_ID}")
try:
# Try to save to keyring (secure storage)
print("\n🔐 Saving to secure storage...")
keyring.set_password("chicom_crawl", "api_key", API_KEY)
keyring.set_password("chicom_crawl", "search_engine_id", SEARCH_ENGINE_ID)
print("✅ Saved to keyring (secure)")
except Exception as e:
print(f"⚠️ Keyring failed: {e}")
print("📁 Falling back to file storage...")
# Fallback to JSON file
settings_dir = Path.home() / ".chicom_crawl"
settings_dir.mkdir(exist_ok=True)
settings_file = settings_dir / "settings.json"
settings = {
'api_key': API_KEY,
'search_engine_id': SEARCH_ENGINE_ID
}
with open(settings_file, 'w') as f:
json.dump(settings, f)
print(f"✅ Saved to {settings_file}")
print("\n🎉 Credentials configured!")
print("💡 Now restart the GUI and the settings should be loaded automatically.")
print("\n▶️ Run: python launch_gui.py")
if __name__ == "__main__":
setup_credentials()