Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-23-2014, 05:48 PM   #16
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi Doitsu,

Yes the "addotherfile" needs the book root relative href since it is for files outside the manifest. Anything in the manifest should be automatically put in the proper place by "addfile" unless I messed up someplace.

Take care,

KevinH

Last edited by KevinH; 11-23-2014 at 05:50 PM.
KevinH is offline   Reply With Quote
Old 11-24-2014, 02:28 PM   #17
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Another day, another question. I need to delete a file (a font) in the ePUB, so I use:
Code:
bk.deletefile(element[1])
The value of 'element[1]' is the manifest id, as it should. The strange thing is, that the manifest is correctly removed from the opf, but not the file itself. It still resides in the font folder. The internal check also does not report that there is an referenced file btw.

Is it a bug or am I doing something wrong?
Toxaris is offline   Reply With Quote
Advert
Old 11-24-2014, 02:59 PM   #18
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
@Toxaris: I was able to reproduce this bug. I also tried bk.deleteotherfile(), which removed the font from the Fonts folder in the Book View window, but not the actual epub file.

@KevinH: deleteotherfile() is defined as:

Code:
    def deleteotherfile(self, book_href):
        # removes file pointed to by the ebook href
        self._w.deleteotherfile(book_href)
IMHO, book_href should be replaced with id.

Last edited by Doitsu; 11-24-2014 at 03:32 PM.
Doitsu is offline   Reply With Quote
Old 11-24-2014, 06:13 PM   #19
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi,

Quote:
Originally Posted by Doitsu View Post
@Toxaris: I was able to reproduce this bug. I also tried bk.deleteotherfile(), which removed the font from the Fonts folder in the Book View window, but not the actual epub file.

@KevinH: deleteotherfile() is defined as:

Code:
    def deleteotherfile(self, book_href):
        # removes file pointed to by the ebook href
        self._w.deleteotherfile(book_href)
IMHO, book_href should be replaced with id.
No, book href is correct for deleteotherfile. It would be incorrect for deletefile.

Kevin
KevinH is offline   Reply With Quote
Old 11-24-2014, 06:17 PM   #20
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi,
No actual deletes are done until the plugin completes. Only the fact you want to delete it should be recorded.

Perhaps there is a bug in the Sigil side not properly handling the delete or not properly updating the list of files in the viewer. Given it passes the check, we probably just need to update the viewer window inside Sigil.

I will look into this.

Thanks for the bug report!

Kevin

Quote:
Originally Posted by Toxaris View Post
Another day, another question. I need to delete a file (a font) in the ePUB, so I use:
Code:
bk.deletefile(element[1])
The value of 'element[1]' is the manifest id, as it should. The strange thing is, that the manifest is correctly removed from the opf, but not the file itself. It still resides in the font folder. The internal check also does not report that there is an referenced file btw.

Is it a bug or am I doing something wrong?
KevinH is offline   Reply With Quote
Advert
Old 11-24-2014, 06:40 PM   #21
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Quote:
Originally Posted by KevinH View Post
Hi,
No actual deletes are done until the plugin completes. Only the fact you want to delete it should be recorded.

Perhaps there is a bug in the Sigil side not properly handling the delete or not properly updating the list of files in the viewer. Given it passes the check, we probably just need to update the viewer window inside Sigil.

I will look into this.

Thanks for the bug report!

Kevin
That was my hunch as well, that the viewer was not updated. However, if I save the ePUB and reopen, the file is still there.
Toxaris is offline   Reply With Quote
Old 11-24-2014, 07:18 PM   #22
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
No, book href is correct for deleteotherfile. It would be incorrect for deletefile.
You may want to double-check this one. If I use your improved code,

Code:
#!/usr/bin/env python
import os, inspect, uuid

def run(bk):
    SCRIPT_DIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
    binary_file = 'WallauRundgotisch-Heavy.ttf'
    binary_path = os.path.join(SCRIPT_DIR, binary_file)
    data = ''
    with open(binary_path, 'rb') as f:
        data = f.read()
    uniqueid = 'id' + str(uuid.uuid4())[24:82]
    bk.addfile(uniqueid, binary_file, data, 'application/x-font-ttf')    

    return 0

def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())
a font file with the href Fonts/WallauRundgotisch-Heavy.ttf will be added.

However, if I subsequently, comment out the last line of the code, replace it with a bk.deleteotherfile() statement and use the above href as the parameter:

Code:
    #bk.addfile(uniqueid, binary_file, data, 'application/x-font-ttf')    
    bk.deleteotherfile('Fonts/WallauRundgotisch-Heavy.ttf')
I'm getting the following error message:

Code:
Traceback (most recent call last):
  File "/usr/local/share/sigil/plugin_launchers//python/launcher.py", line 137, in launch
    self.exitcode = target_script.run(container)
  File "/home/user/.local/share/sigil-ebook/sigil/plugins/test/plugin.py", line 13, in run
    bk.deleteotherfile('Fonts/WallauRundgotisch-Heavy.ttf')
  File "/usr/local/share/sigil/plugin_launchers/python/bookcontainer.py", line 143, in deleteotherfile
    self._w.deleteotherfile(book_href)
  File "/usr/local/share/sigil/plugin_launchers/python/wrapper.py", line 565, in deleteotherfile
    del self.id_to_filepath[id]
KeyError: u'Fonts/WallauRundgotisch-Heavy.ttf'
Error: u'Fonts/WallauRundgotisch-Heavy.ttf'
However, if I use the id instead of the href, I get no error message and the file is deleted both from the fonts folder and the manifest (but not from the actual epub file.)

D.
Doitsu is offline   Reply With Quote
Old 11-24-2014, 07:57 PM   #23
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi Doitsu,

Please do not try and delete files that exist in the manifest with the "other" family of interface calls.

deletefile
addfile
readfile
writefile

are all designed to work only on manifest files. The new version of the launcher code will enforce that.

Almost all files should be in the manifest. To access files not in the manifest such as container.xml, mimetype, OEBPS/content.opf etc, you would use the following interface routines:

readotherfile
writeotherfile
addotherfile
deleteotherfile

There is a serious bug in the deletefile interface in both the wrapper.py and in the launcher.py that I now have a fix for. I will post them in one minute so please hang on.

Thanks!

KevinH

Last edited by KevinH; 11-24-2014 at 09:00 PM.
KevinH is offline   Reply With Quote
Old 11-24-2014, 08:06 PM   #24
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
deletefile bug fix

Hi Toxaris and Doitsu,

There was a serious "thinko" in how I implemented how the plugin deletes files in the manifest that needed to be fixed. The previous version worked on files I added via plugin, but not on files that only existed in the original ebook.

I have now fixed that. Attached are two new versions of wrapper.py and launcher.py.

I have now committed them to my tree so hopefully they will be in time to make the upcoming release for Sigil 0.8.2

Also, since I can see that the launcher code needs to be updated faster that the Sigil main codebase (especially considering how many bugs you guys are finding!), I have developed a launcher_updater program, so that I can release launcher updates more frequently.

I have a rough working version of the launcher_updater but need to polish it before making my first release.

So until then, please grab and unzip the two files attached and add them to your plugin launcher code to replace their namesakes.

When Sigil 0.8.2 does come out, all of these changes will be included.

Please let me know if this does the trick.

KevinH

ps. DiapDealer just found and fixed another bug in deletefile so I have updated the wrapper.py yet again. When it rains it pours!!!

Last edited by KevinH; 11-25-2014 at 04:27 PM. Reason: removed attachments see later launcher_modified.zip post
KevinH is offline   Reply With Quote
Old 11-25-2014, 06:42 AM   #25
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
Great, will test it out tonight. With some luck I can polish it enough to be able to release my plugin tonight as well. It will be a font subsetter and image optimizer.
Toxaris is offline   Reply With Quote
Old 11-25-2014, 12:07 PM   #26
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
I get two errors in wrapper.py:
First a popup that says: Error parsing result XML: Premature end of document

Second the following error:
Traceback (most recent call last):
File "C:\Program Files\Sigil\plugin_launchers\\python\launcher.py", line 62, in <module>
from validationcontainer import ValidationContainer
ImportError: No module named validationcontainer

Of course I replaced both files you posted.

Last edited by Toxaris; 11-25-2014 at 12:11 PM.
Toxaris is offline   Reply With Quote
Old 11-25-2014, 12:07 PM   #27
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi Toxaris,

Unfortunately there are changes inside Sigil that are needed to make this version work. I will modify something for you to test with that does not need Sigil to be changed and post it for you this evening.

Sorry about that, I am using and testing with a pre-release version of Sigil 0.8.2 and not the version you are using.

Kevin
KevinH is offline   Reply With Quote
Old 11-25-2014, 12:17 PM   #28
KevinH
Sigil Developer
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: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi Toxaris,

I stole a free moment at work to try and turn off the feature that allows plugin prints to appear immediately in the Sigil window. This feature requires changes in Sigil as well.

So please try the following version of launcher.py that should disable this new feature and hopefully work for you.

Sorry about that. I keep forgetting that Sigil 0.8.2 is not out yet!

KevinH

ps. To get around your second error you will need to add the following files to the plugin_launcher as well (after unzipping).

Last edited by KevinH; 11-25-2014 at 04:27 PM. Reason: Removed incomplete fix - see later launcher_modifed.zip post for full set
KevinH is offline   Reply With Quote
Old 11-25-2014, 01:16 PM   #29
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Unfortunately, the latest launcher version causes the following error message:

Code:
Traceback (most recent call last):
  File "/usr/local/share/sigil/plugin_launchers//python/launcher.py", line 30, in <module>
    from compatibility_utils import PY3, text_type, utf8_str, unicode_str, unescapeit

ImportError: cannot import name unescapeit
Doitsu is offline   Reply With Quote
Old 11-25-2014, 01:29 PM   #30
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Doitsu View Post
Unfortunately, the latest launcher version causes the following error message:

Code:
Traceback (most recent call last):
  File "/usr/local/share/sigil/plugin_launchers//python/launcher.py", line 30, in <module>
    from compatibility_utils import PY3, text_type, utf8_str, unicode_str, unescapeit

ImportError: cannot import name unescapeit
Do you have the compatibility_utils installed? The latest one?

At this point, your best bet is to grab all the latest launcher files from Kevin's github and then replace launcher.py with the most recent one he posted in this thread. That's what I did with Sigil 0.8.1 and everything worked as it should.
DiapDealer is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 07:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-05-2012 12:33 AM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 10:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 01:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 01:44 PM


All times are GMT -4. The time now is 11:05 PM.


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