refactor: Change logging level from info to debug for download and JS messages
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled
This commit is contained in:
parent
6d8af7f8fb
commit
dffc925bb6
2 changed files with 30 additions and 34 deletions
|
|
@ -238,7 +238,7 @@ class _DragBridge(QObject):
|
|||
Args:
|
||||
message: Debug message from JavaScript
|
||||
"""
|
||||
logger.info(f"JS Debug: {message}")
|
||||
logger.debug(f"JS Debug: {message}")
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
|
|
@ -327,7 +327,7 @@ class MainWindow(QMainWindow):
|
|||
|
||||
# Set up download handler
|
||||
profile = self.web_view.page().profile()
|
||||
logger.info(f"Connecting download handler to profile: {profile}")
|
||||
logger.debug(f"Connecting download handler to profile: {profile}")
|
||||
|
||||
# CRITICAL: Connect download handler BEFORE any page loads
|
||||
profile.downloadRequested.connect(self._on_download_requested)
|
||||
|
|
@ -338,9 +338,9 @@ class MainWindow(QMainWindow):
|
|||
)
|
||||
if downloads_path:
|
||||
profile.setDownloadPath(downloads_path)
|
||||
logger.info(f"Download path set to: {downloads_path}")
|
||||
logger.debug(f"Download path set to: {downloads_path}")
|
||||
|
||||
logger.info("Download handler connected successfully")
|
||||
logger.debug("Download handler connected successfully")
|
||||
|
||||
# Set up central widget with layout
|
||||
central_widget = QWidget()
|
||||
|
|
@ -820,17 +820,13 @@ class MainWindow(QMainWindow):
|
|||
Args:
|
||||
download: Download request from the web engine
|
||||
"""
|
||||
logger.info("=" * 60)
|
||||
logger.info("🔥 DOWNLOAD REQUESTED - Handler called!")
|
||||
logger.info("=" * 60)
|
||||
|
||||
try:
|
||||
# Log all download details for debugging
|
||||
logger.info(f"Download URL: {download.url().toString()}")
|
||||
logger.info(f"Download filename: {download.downloadFileName()}")
|
||||
logger.info(f"Download mime type: {download.mimeType()}")
|
||||
logger.info(f"Download suggested filename: {download.suggestedFileName()}")
|
||||
logger.info(f"Download state: {download.state()}")
|
||||
# Log download details for debugging
|
||||
logger.debug(f"Download URL: {download.url().toString()}")
|
||||
logger.debug(f"Download filename: {download.downloadFileName()}")
|
||||
logger.debug(f"Download mime type: {download.mimeType()}")
|
||||
logger.debug(f"Download suggested filename: {download.suggestedFileName()}")
|
||||
logger.debug(f"Download state: {download.state()}")
|
||||
|
||||
# Get the system's Downloads folder
|
||||
downloads_path = QStandardPaths.writableLocation(
|
||||
|
|
@ -850,14 +846,14 @@ class MainWindow(QMainWindow):
|
|||
|
||||
# Construct full download path
|
||||
download_file = Path(downloads_path) / filename
|
||||
logger.info(f"📁 Download will be saved to: {download_file}")
|
||||
logger.debug(f"Download will be saved to: {download_file}")
|
||||
|
||||
# Set download path and accept
|
||||
download.setDownloadDirectory(str(download_file.parent))
|
||||
download.setDownloadFileName(download_file.name)
|
||||
download.accept()
|
||||
|
||||
logger.info(f"✅ Download accepted and started: {download_file}")
|
||||
logger.info(f"Download started: {filename}")
|
||||
|
||||
# Update status bar (temporarily)
|
||||
self.status_bar.showMessage(
|
||||
|
|
@ -866,7 +862,7 @@ class MainWindow(QMainWindow):
|
|||
|
||||
# Connect to state changed for progress tracking
|
||||
download.stateChanged.connect(
|
||||
lambda state: logger.info(f"Download state changed to: {state}")
|
||||
lambda state: logger.debug(f"Download state changed to: {state}")
|
||||
)
|
||||
|
||||
# Connect to finished signal for completion feedback
|
||||
|
|
@ -875,8 +871,8 @@ class MainWindow(QMainWindow):
|
|||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Error handling download: {e}", exc_info=True)
|
||||
self.status_bar.showMessage(f"❌ Download-Fehler: {e}", 5000)
|
||||
logger.error(f"Error handling download: {e}", exc_info=True)
|
||||
self.status_bar.showMessage(f"Download error: {e}", 5000)
|
||||
|
||||
def _on_download_finished(self, download: QWebEngineDownloadRequest, file_path: Path) -> None:
|
||||
"""Handle download completion.
|
||||
|
|
@ -890,12 +886,12 @@ class MainWindow(QMainWindow):
|
|||
return
|
||||
|
||||
state = download.state()
|
||||
logger.info(f"Download finished with state: {state}")
|
||||
logger.debug(f"Download finished with state: {state}")
|
||||
|
||||
if state == QWebEngineDownloadRequest.DownloadState.DownloadCompleted:
|
||||
logger.info(f"Download completed successfully: {file_path}")
|
||||
logger.info(f"Download completed: {file_path.name}")
|
||||
self.status_bar.showMessage(
|
||||
f"✅ Download abgeschlossen: {file_path.name}", 5000
|
||||
f"Download completed: {file_path.name}", 5000
|
||||
)
|
||||
elif state == QWebEngineDownloadRequest.DownloadState.DownloadCancelled:
|
||||
logger.info(f"Download cancelled: {file_path.name}")
|
||||
|
|
@ -959,7 +955,7 @@ class MainWindow(QMainWindow):
|
|||
|
||||
# Map JS log levels to Python log levels using enum
|
||||
if level == QWebEnginePage.JavaScriptConsoleMessageLevel.InfoMessageLevel:
|
||||
logger.info(f"JS Console: {message}")
|
||||
logger.debug(f"JS Console: {message}")
|
||||
elif level == QWebEnginePage.JavaScriptConsoleMessageLevel.WarningMessageLevel:
|
||||
logger.warning(f"JS Console: {message}")
|
||||
logger.debug(f" at {source_id}:{line_number}")
|
||||
|
|
@ -982,11 +978,11 @@ class MainWindow(QMainWindow):
|
|||
# Check if bridge script is loaded
|
||||
def check_script(result):
|
||||
if result:
|
||||
logger.info("✓ WebDrop Bridge script is active")
|
||||
logger.info("✓ QWebChannel bridge is ready")
|
||||
logger.debug("WebDrop Bridge script is active")
|
||||
logger.debug("QWebChannel bridge is ready")
|
||||
else:
|
||||
logger.error("✗ WebDrop Bridge script NOT loaded!")
|
||||
logger.error(" Drag-and-drop conversion will NOT work")
|
||||
logger.error("WebDrop Bridge script NOT loaded!")
|
||||
logger.error("Drag-and-drop conversion will not work")
|
||||
|
||||
# Execute JS to check if our script is loaded
|
||||
self.web_view.page().runJavaScript(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue