View Single Post
Old 09-09-2019, 04:39 PM   #1
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
ScrambleBook and Calibre 4

I'm trying to get my ScrambleEbook user interface plugin working in the beta but I'm having a problem importing QWebEngineView.

This is the import code at the top of the main .py file:
Code:
try:
    from PyQt5.QtWebKitWidgets import QWebView as Webview
    print('PyQt5.QtWebKitWidgets.QWebView OK')
except:
    print('PyQt5.QtWebKitWidgets.QWebView failed')
    try:
        from PyQt5.QtWebEngineWidgets import QWebEngineView as Webview 
        print('PyQt5.QtWebEngineWidgets.QWebEngineView OK')
    except:
        print('PyQt5.QtWebEngineWidgets.QWebEngineView failed')
Under 3.47.1 the first try is successful and everything seems to be working OK.

In beta 3.99.1 I'd expect the first try to fail and the second to succeed. However, both of them fail. You can see the error message prints (in red) during calibre startup in debug mode. Despite the error messages, the plugin does get installed.
Spoiler:
Code:
D:\sysfiles\Port_Progs\npp>echo off 
D:\sysfiles\calibre\calcache
calibre 3.99.1  embedded-python: True is64bit: False
Windows-10-10.0.18362-SP0 Windows ('32bit', 'WindowsPE')
32bit process running on 64bit windows
('Windows', '10', '10.0.18362')
Python 2.7.16+
Windows: ('10', '10.0.18362', 'SP0', u'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeDRM (6, 6, 2) && Search The Internet (1, 7, 6) && EpubModBuild (0, 1, 10) && Goodreads (1, 4, 0) && EpubCheck (0, 1, 9) && Copy Cover To Device (2, 0, 0) && TTS to MP3 (0, 1, 5) && KePub Metadata Reader (3, 0, 2) && KePub Metadata Writer (3, 0, 3) && JS_Modify_Epub (0, 0, 8) && FlightCrew (0, 0, 3) && Barnes & Noble (1, 2, 15) && Kobo Utilities (2, 8, 0) && KoboTouchExtended (3, 1, 5) && Device Old Books (0, 0, 1) && ScrambleEbook (0, 0, 9) && EpubModBuildJobs (0, 0, 10) && Epub2Kepub (0, 0, 34) && Quality Check (1, 9, 11) && Fantastic Fiction (1, 3, 0) && DOC Input (1, 0, 1) && Kobo Books (1, 7, 0) && KePub Input (3, 0, 0) && Extract ISBN (2, 0, 0) && KindleUnpack - The Plugin (0, 81, 5) && JS_Editor_Tools (0, 2, 40) && Count Pages (1, 8, 2) && Kindle hi-res covers (0, 4, 0) && Obok DeDRM (6, 5, 4)
Turning on automatic hidpi scaling
Registering with default programs...
devicePixelRatio: 1.0
logicalDpi: 96.0 x 96.0
physicalDpi: 127.664921466 x 127.590697674
Using calibre Qt style: True
[0.00] Starting up...
[0.00] Initializing db...
Registered with default programs in 1.0 seconds
[0.61] db initialized
[0.61] Constructing main UI...
calibre css_parser 1.0.4
lxml etree: 4.3.3
DEBUG:    0.0 KoboUtilites::action.py - loading translations
DEBUG:    0.0 KoboUtilites::dialogs.py - loading translations
DEBUG:    0.0 KoboUtilites::action.py - loading translations
PyQt5.QtWebKitWidgets.QWebView failed
PyQt5.QtWebEngineWidgets.QWebEngineView failed
DEBUG:    0.0 obok::utilities.py - loading translations
DEBUG:    0.0 obok::dialogs.py - loading translations
DEBUG:    0.0 obok::config.py - loading translations
DEBUG:    0.0 obok::action_err.py - loading translations
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
DEBUG:    1.9 No Kobo Touch, Glo or Mini appears to be connected
DEBUG:    1.9 rebuild_menus - self.supports_ratings=None, self.supports_tiles=None
DEBUG:    1.9 KoboUtilities:set_toolbar_button_tooltip - start: text='None'
DEBUG:    1.9 KoboUtilities:set_toolbar_button_tooltip - setting to text='Utilities to use with Kobo ereaders

Driver: KoboTouchExtended'
[3.70] main UI initialized...
[3.70] Started up in 3.70 seconds with 181 books
SMART_DEV (   0.00:  0.002) _attach_to_port try ip address "" on port 9090
SMART_DEV (   0.96:  0.830) _startup_on_demand listening on port 9090
SMART_DEV (   0.99:  0.000) _attach_to_port try ip address "" on port 54982
SMART_DEV (   1.03:  0.000) _startup_on_demand broadcast socket listening on port 54982
SMART_DEV (   2.12:  1.055) run All IP addresses {u'{B5C0D296-CA26-11E7-AD69-806E6F6E6963}': [{'broadcast': u'127.255.255.255', 'addr': u'127.0.0.1', 'netmask': u'255.0.0.0'}], u'{B707974E-9488-42B1-BAAD-254627B9DE69}': [{'broadcast': u'192.168.0.255', 'addr': u'192.168.0.7', 'netmask': u'255.255.255.0'}]}


The more obvious error message happens when running the plugin and pressing the 'Preview content' button - which is the only place the QWebView/QWebEngineView widget is used.
Spoiler:
Code:
calibre, version 3.99.1
ERROR: Unhandled exception: <b>NameError</b>:global name 'Webview' is not defined

calibre 3.99.1  embedded-python: True is64bit: False
Windows-10-10.0.18362-SP0 Windows ('32bit', 'WindowsPE')
32bit process running on 64bit windows
('Windows', '10', '10.0.18362')
Python 2.7.16+
Windows: ('10', '10.0.18362', 'SP0', u'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeDRM (6, 6, 2) && Search The Internet (1, 7, 6) && EpubModBuild (0, 1, 10) && Goodreads (1, 4, 0) && EpubCheck (0, 1, 9) && Copy Cover To Device (2, 0, 0) && TTS to MP3 (0, 1, 5) && KePub Metadata Reader (3, 0, 2) && KePub Metadata Writer (3, 0, 3) && JS_Modify_Epub (0, 0, 8) && FlightCrew (0, 0, 3) && Barnes & Noble (1, 2, 15) && Kobo Utilities (2, 8, 0) && KoboTouchExtended (3, 1, 5) && Device Old Books (0, 0, 1) && ScrambleEbook (0, 0, 9) && EpubModBuildJobs (0, 0, 10) && Epub2Kepub (0, 0, 34) && Quality Check (1, 9, 11) && Fantastic Fiction (1, 3, 0) && DOC Input (1, 0, 1) && Kobo Books (1, 7, 0) && KePub Input (3, 0, 0) && Extract ISBN (2, 0, 0) && KindleUnpack - The Plugin (0, 81, 5) && JS_Editor_Tools (0, 2, 40) && Count Pages (1, 8, 2) && Kindle hi-res covers (0, 4, 0) && Obok DeDRM (6, 5, 4)
Traceback (most recent call last):
  File "calibre_plugins.scrambleebook_plugin.scrambleebook", line 363, in preview_ebook
  File "calibre_plugins.scrambleebook_plugin.scrambleebook", line 860, in __init__
NameError: global name 'Webview' is not defined


I'm confused because in one of my personal Editor Tool plugins I've used the same import approach and both 3.47.1 and 3.99.1 seem to be working fine.

I've also attached a copy of the plugin in it's current state if you have time to look at it. If not I'll ask again when the initial beta bug reporting dies down a bit.
Attached Files
File Type: zip ScrambleEbook_beta.zip (112.4 KB, 311 views)
jackie_w is offline   Reply With Quote