Implement configuration management, drag-and-drop functionality, and logging utilities for WebDrop Bridge
This commit is contained in:
parent
04ef84cf9a
commit
6bef2f6119
9 changed files with 1154 additions and 0 deletions
67
src/webdrop_bridge/main.py
Normal file
67
src/webdrop_bridge/main.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
"""WebDrop Bridge - Application entry point."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from webdrop_bridge.config import Config, ConfigurationError
|
||||
from webdrop_bridge.ui.main_window import MainWindow
|
||||
from webdrop_bridge.utils.logging import get_logger, setup_logging
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""Main application entry point.
|
||||
|
||||
Initializes configuration, logging, and creates the main window.
|
||||
Returns appropriate exit code.
|
||||
|
||||
Returns:
|
||||
int: Exit code (0 for success, non-zero for error)
|
||||
"""
|
||||
try:
|
||||
# Load configuration from environment
|
||||
config = Config.from_env()
|
||||
|
||||
# Set up logging
|
||||
log_file = None
|
||||
if config.log_file_path:
|
||||
log_file = Path(config.log_file_path)
|
||||
|
||||
setup_logging(
|
||||
name="webdrop_bridge",
|
||||
level=config.log_level,
|
||||
log_file=log_file,
|
||||
)
|
||||
|
||||
logger = get_logger(__name__)
|
||||
logger.info(f"Starting {config.app_name} v{config.app_version}")
|
||||
logger.debug(f"Configuration: {config}")
|
||||
|
||||
except ConfigurationError as e:
|
||||
print(f"Configuration error: {e}", file=sys.stderr)
|
||||
return 1
|
||||
except Exception as e:
|
||||
print(f"Failed to initialize logging: {e}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
try:
|
||||
# Create Qt application
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# Create and show main window
|
||||
window = MainWindow(config)
|
||||
window.show()
|
||||
|
||||
logger.info("Main window opened successfully")
|
||||
|
||||
# Run event loop
|
||||
return app.exec()
|
||||
|
||||
except Exception as e:
|
||||
logger.exception(f"Unhandled exception: {e}")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue