|
33 | 33 | from functools import partial
|
34 | 34 | from random import uniform
|
35 | 35 | from operator import itemgetter
|
| 36 | +import logging |
36 | 37 |
|
37 | 38 | import openshot # Python module for libopenshot (required video editing module installed separately)
|
38 | 39 | from PyQt5.QtCore import QFileInfo, pyqtSlot, QUrl, Qt, QCoreApplication, QTimer
|
@@ -174,13 +175,15 @@ def get_thumb_address(self):
|
174 | 175 | thumb_address = "http://%s:%s/thumbnails/" % (thumb_server_details[0], thumb_server_details[1])
|
175 | 176 | return thumb_address
|
176 | 177 |
|
177 |
| - def run_js(self, code, callback=None): |
| 178 | + def run_js(self, code, callback=None, retries=0): |
178 | 179 | '''Run JS code async and optionally have a callback for response'''
|
179 | 180 | # Check if document.Ready has fired in JS
|
180 | 181 | if not self.document_is_ready:
|
181 | 182 | # Not ready, try again in a few moments
|
182 |
| - log.error("TimelineWebView::run_js() called before document ready event. Script queued: %s" % code) |
183 |
| - QTimer.singleShot(50, partial(self.run_js, code, callback)) |
| 183 | + if retries > 0 and retries % 5 == 0: |
| 184 | + log.warning("WebEngine backend still not processing requests, queueing script.") |
| 185 | + log.debug("TimelineWebView::run_js() called before document ready event. Script queued: %s" % code) |
| 186 | + QTimer.singleShot(50, partial(self.run_js, code, callback, retries + 1)) |
184 | 187 | return None
|
185 | 188 | else:
|
186 | 189 | # Execute JS code
|
@@ -2719,6 +2722,21 @@ def removeSelection(self, item_id, item_type):
|
2719 | 2722 | def qt_log(self, message=None):
|
2720 | 2723 | log.info(message)
|
2721 | 2724 |
|
| 2725 | + @pyqtSlot(str, str) |
| 2726 | + def qt_log2(self, level="INFO", message=None): |
| 2727 | + levels = { |
| 2728 | + "DEBUG": logging.DEBUG, |
| 2729 | + "INFO": logging.INFO, |
| 2730 | + "WARN": logging.WARNING, |
| 2731 | + "WARNING": logging.WARNING, |
| 2732 | + "ERROR": logging.ERROR, |
| 2733 | + "CRITICAL": logging.CRITICAL, |
| 2734 | + "FATAL": logging.FATAL, |
| 2735 | + } |
| 2736 | + if isinstance(level, str): |
| 2737 | + level = levels.get(level, logging.INFO) |
| 2738 | + log.log(level, message) |
| 2739 | + |
2722 | 2740 | # Handle changes to zoom level, update js
|
2723 | 2741 | def update_zoom(self, newValue):
|
2724 | 2742 | _ = get_app()._tr
|
|
0 commit comments