webdrop-bridge/src/webdrop_bridge/main.py
claudi 88dc358894 Refactor drag handling and update tests
- Renamed `initiate_drag` to `handle_drag` in MainWindow and updated related tests.
- Improved drag handling logic to utilize a bridge for starting file drags.
- Updated `_on_drag_started` and `_on_drag_failed` methods to match new signatures.
- Modified test cases to reflect changes in drag handling and assertions.

Enhance path validation and logging

- Updated `PathValidator` to log warnings for nonexistent roots instead of raising errors.
- Adjusted tests to verify the new behavior of skipping nonexistent roots.

Update web application UI and functionality

- Changed displayed text for drag items to reflect local paths and Azure Blob Storage URLs.
- Added debug logging for drag operations in the web application.
- Improved instructions for testing drag and drop functionality.

Add configuration documentation and example files

- Created `CONFIG_README.md` to provide detailed configuration instructions for WebDrop Bridge.
- Added `config.example.json` and `config_test.json` for reference and testing purposes.

Implement URL conversion logic

- Introduced `URLConverter` class to handle conversion of Azure Blob Storage URLs to local paths.
- Added unit tests for URL conversion to ensure correct functionality.

Develop download interceptor script

- Created `download_interceptor.js` to intercept download-related actions in the web application.
- Implemented logging for fetch calls, XMLHttpRequests, and Blob URL creations.

Add download test page and related tests

- Created `test_download.html` for testing various download scenarios.
- Implemented `test_download.py` to verify download path resolution and file construction.
- Added `test_url_mappings.py` to ensure URL mappings are loaded correctly.

Add unit tests for URL converter

- Created `test_url_converter.py` to validate URL conversion logic and mapping behavior.
2026-02-17 15:56:53 +01:00

73 lines
2 KiB
Python

"""WebDrop Bridge - Application entry point."""
import sys
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 file if it exists, otherwise from environment
config_path = Config.get_default_config_path()
if config_path.exists():
config = Config.from_file(config_path)
else:
config = Config.from_env()
# Set up logging
log_file = None
if config.log_file:
log_file = config.log_file
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")
# Check for updates on startup (non-blocking, async)
window.check_for_updates_startup()
# Run event loop
return app.exec()
except Exception as e:
logger.exception(f"Unhandled exception: {e}")
return 1
if __name__ == "__main__":
sys.exit(main())