Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 12-13-2014, 08:18 AM   #1
turbulent
Member
turbulent began at the beginning.
 
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.
turbulent is offline   Reply With Quote
Old 12-13-2014, 10:29 AM   #2
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 4,288
Karma: 2621140
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:
Originally Posted by turbulent View Post
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.
KevinH is offline   Reply With Quote
Advert
Old 12-13-2014, 11:24 PM   #3
turbulent
Member
turbulent began at the beginning.
 
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?
turbulent is offline   Reply With Quote
Old 12-14-2014, 08:22 AM   #4
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 4,288
Karma: 2621140
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
KevinH is offline   Reply With Quote
Old 12-14-2014, 08:43 AM   #5
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 4,288
Karma: 2621140
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
KevinH is offline   Reply With Quote
Advert
Old 12-15-2014, 02:06 PM   #6
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 4,288
Karma: 2621140
Join Date: Nov 2009
Device: many
Hi,

I have now removed the warning. This fix should appear in the next release of Sigil.

KevinH
KevinH is offline   Reply With Quote
Old 12-16-2014, 08:56 AM   #7
turbulent
Member
turbulent began at the beginning.
 
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
Quote:
Originally Posted by KevinH View Post
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
Hi, Kevin

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
Running this plugin, the message is:
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
"variable_not_exist" is undefined to trigger the error. I expect the message "This line should be displayed." to show up. But it didn't.
turbulent is offline   Reply With Quote
Old 12-16-2014, 09:03 AM   #8
turbulent
Member
turbulent began at the beginning.
 
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
Quote:
Originally Posted by KevinH View Post
Hi,

I have now removed the warning. This fix should appear in the next release of Sigil.

KevinH
So nice of you! Thanks for your effort in providing us more and more wonderful Sigil for editing epub files.
turbulent is offline   Reply With Quote
Old 12-16-2014, 10:39 AM   #9
KevinH
Wizard
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 4,288
Karma: 2621140
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:
Originally Posted by turbulent View Post
Hi, Kevin

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
Running this plugin, the message is:
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
"variable_not_exist" is undefined to trigger the error. I expect the message "This line should be displayed." to show up. But it didn't.
KevinH is offline   Reply With Quote
Old 12-17-2014, 07:11 AM   #10
turbulent
Member
turbulent began at the beginning.
 
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
Hi, Kevin

I think I understand it. Thanks for your detailed explanation.
turbulent is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
kindlegen plugin for Sigil Doitsu Plugins 133 04-15-2020 09:34 PM
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


All times are GMT -4. The time now is 06:19 AM.


MobileRead.com is a privately owned, operated and funded community.