12-13-2014, 08:18 AM | #1 |
Member
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
|
UnicodeWarning when running Sigil plugin
When running a Sigil plugin, if the current path contains non-ASCII character, the plugin runner dialog will display the message:
C:\Program Files\Sigil\plugin_launchers\\python\launcher.py:2 43: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal if script_home not in sys.path: The message is displayed only when the plugin is running. When the plugin finishes running, the message will be replaced by the output of plugin. |
12-13-2014, 10:29 AM | #2 | |
Sigil Developer
Posts: 7,655
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi turbulent,
I think this is an artifact of python 2.7, that keeps its internal search paths as bytestrings, not full unicode. The launcher itself is full unicode. Being marked as unequal is the safest path forward and should not hurt anything. If the plugin actually started then this warning can be safely ignored. I will include a work around for this for python 2.7 in the next release to prevent the warning. Thank you for your bug report! KevinH Quote:
|
|
Advert | |
|
12-13-2014, 11:24 PM | #3 |
Member
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
|
Hi KevinH,
Yes, I'm using Python 2.7 with Sigil 0.8.2. I'm glad that this warning is not a big deal and can be ignored. I've another question about errors. I'm learning to write my own plugin now. I used to add some print statement in the script for debug purpose. But I find that for Sigil plugin, the stdout is displayed only when the plugin returned successfully. When something goes wrong and throws a exception, only the error message is displayed, and I lose the helpful hints from the "prints". I wonder whether there is kind of "best practise" in the situation? |
12-14-2014, 08:22 AM | #4 |
Sigil Developer
Posts: 7,655
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi,
That was fixed in Sigil 0.8.2. Are you sure you are using the very latest version? Cuurently a print statement will show up immediately in the PluginRunner Window. Kevin |
12-14-2014, 08:43 AM | #5 |
Sigil Developer
Posts: 7,655
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi,
And the full traceback of the exception should get caught and printed in the launcher unless you catch the exception yourself. Kevin |
Advert | |
|
12-15-2014, 02:06 PM | #6 |
Sigil Developer
Posts: 7,655
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi,
I have now removed the warning. This fix should appear in the next release of Sigil. KevinH |
12-16-2014, 08:56 AM | #7 | |
Member
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
|
Quote:
I'm using Sigil 0.8.2 on Win7. I create a test plugin as below: Code:
def run(bk): print 'This line should be displayed.' print variable_not_exist return 0 Code:
Status: failed Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\\python\launcher.py", line 135, in launch self.exitcode = target_script.run(container) File "C:\Users\xj\AppData\Local\sigil-ebook\sigil\plugins\test\plugin.py", line 7, in run print variable_not_exist NameError: global name 'variable_not_exist' is not defined Error: global name 'variable_not_exist' is not defined |
|
12-16-2014, 09:03 AM | #8 |
Member
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
|
|
12-16-2014, 10:39 AM | #9 | |
Sigil Developer
Posts: 7,655
Karma: 5433388
Join Date: Nov 2009
Device: many
|
Hi,
It actually did but was quickly replaced with the error message when the plugin-ended. So if you were to run a longer plugin you would see that print output. That way the plugin can update the user using simple print statements while running longer tasks. If you use your own try/catch block and handle the error, you would see the print output. But as soon as the plugin completes it will show either stdout on success or stderror on failure and not some asynchronous mix. Hope this explains how things are meant to work. KevinH Quote:
|
|
12-17-2014, 07:11 AM | #10 |
Member
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
|
Hi, Kevin
I think I understand it. Thanks for your detailed explanation. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
kindlegen plugin for Sigil | Doitsu | Plugins | 169 | 02-16-2024 06:48 AM |
smoothRemove_v010 plugin for Sigil | kbanelas | Plugins | 15 | 01-27-2017 05:51 PM |
Reporting an error when running Sigil 0.8.2 | turbulent | Sigil | 2 | 12-13-2014 10:23 PM |
linux variants for running sigil | rakulos | Sigil | 4 | 12-07-2012 05:37 AM |
Two issues running Sigil under KDE4 (using system Qt4) | Ahmad Samir | Sigil | 6 | 06-02-2011 01:19 PM |