refactor to centralize, move to desktop type
This commit is contained in:
22
main.py
22
main.py
@@ -4,17 +4,23 @@ import os
|
||||
import sys
|
||||
from importlib import metadata
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file BEFORE any other imports
|
||||
# This ensures OAuth config gets the right environment variables
|
||||
dotenv_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '.env')
|
||||
load_dotenv(dotenv_path=dotenv_path)
|
||||
|
||||
# Now import modules that depend on environment variables
|
||||
from core.server import server, set_transport_mode, configure_server_for_http
|
||||
|
||||
# Reload OAuth config after loading .env to pick up credentials
|
||||
from auth.oauth_config import reload_oauth_config
|
||||
reload_oauth_config()
|
||||
|
||||
# Suppress googleapiclient discovery cache warning
|
||||
logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR)
|
||||
from core.utils import check_credentials_directory_permissions
|
||||
|
||||
# Load environment variables from .env file, specifying an explicit path
|
||||
# This prevents accidentally loading a .env file from a different directory
|
||||
dotenv_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '.env')
|
||||
load_dotenv(dotenv_path=dotenv_path)
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
@@ -92,6 +98,7 @@ def main():
|
||||
# Active Configuration
|
||||
safe_print("⚙️ Active Configuration:")
|
||||
|
||||
|
||||
# Redact client secret for security
|
||||
client_secret = os.getenv('GOOGLE_OAUTH_CLIENT_SECRET', 'Not Set')
|
||||
redacted_secret = f"{client_secret[:4]}...{client_secret[-4:]}" if len(client_secret) > 8 else "Invalid or too short"
|
||||
@@ -140,11 +147,11 @@ def main():
|
||||
|
||||
# Import specified tools or all tools if none specified
|
||||
tools_to_import = args.tools if args.tools is not None else tool_imports.keys()
|
||||
|
||||
|
||||
# Set enabled tools for scope management
|
||||
from auth.scopes import set_enabled_tools
|
||||
set_enabled_tools(list(tools_to_import))
|
||||
|
||||
|
||||
safe_print(f"🛠️ Loading {len(tools_to_import)} tool module{'s' if len(tools_to_import) != 1 else ''}:")
|
||||
for tool in tools_to_import:
|
||||
tool_imports[tool]()
|
||||
@@ -153,7 +160,6 @@ def main():
|
||||
|
||||
safe_print("📊 Configuration Summary:")
|
||||
safe_print(f" 🔧 Tools Enabled: {len(tools_to_import)}/{len(tool_imports)}")
|
||||
safe_print(" 🔑 Auth Method: OAuth 2.0 with PKCE")
|
||||
safe_print(f" 📝 Log Level: {logging.getLogger().getEffectiveLevel()}")
|
||||
safe_print("")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user