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

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-28-2011, 05:48 AM   #1
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
User Interface Plugin Creation/Debug process

I've read through the plugin tutorial on the main Calibre site, and there was one bit I wanted to clarify.

Is this the primary method to modify/debug these plugins?:
  1. Make your changes
  2. Re-zip the plugin files
  3. Uninstall/Install the new version to Calibre using the GUI
  4. Re-start Calibre
  5. Test
Are there any tips for reducing/simplifying those steps?
ldolse is offline   Reply With Quote
Old 04-28-2011, 05:59 AM   #2
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
To answer my own question, I just missed this on the first read through the tutorial:
Quote:
It can get tiresome to keep re-adding a plugin to calibre to test small changes. The plugin zip files are stored in the calibre config directory in plugins/ (goto Preferences->Misc and click open config directory to see the config directory).

Once you’ve located the zip file of your plugin you can then directly update it with your changes instead of re-adding it each time. To do so from the command line, in the directory that contains your plugin source code, use:

zip -R /path/to/plugin/zip/file.zip *
This will update all changed files. It relies on the freely available zip command line tool. Note that you should quit calibre before running this command.

Last edited by ldolse; 04-28-2011 at 06:21 AM.
ldolse is offline   Reply With Quote
Advert
Old 04-28-2011, 06:02 AM   #3
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
I posted a batch file here that I use.

I make this part of my project folder in Eclipse so in the package explorer I can directly just double click on it. This rebuilds the zip, re-installs it into Calibre and starts calibre in debug mode. You just need to remember to close Calibre before you next run it again.

You can directly test preferences configuration screens etc using __main__ test stubs in the class files but I've never really found that particularly useful for user interface plugins, mainly because I am wanting to test the result of changing a setting rather than just the configuration screen itself.
kiwidude is offline   Reply With Quote
Old 04-28-2011, 08:13 AM   #4
meme
Sigil developer
meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.meme ought to be getting tired of karma fortunes by now.
 
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
This is how I do it as well. A simple batch script (I include mine in the plugin's zip). And a second one when running from source just to set the source path. No need to uninstall - just install on top. And Calibre will remember your icon/menu setup so you don't have to re-add it. I used to have test stubs but they weren't of any real use once I got it running.

There is a lot of run, fix typo, run, tweak, run Sometimes even run, forget to tweak, run again and get very confused And with a device its wait 5/6 seconds before you can test...
meme is offline   Reply With Quote
Old 04-28-2011, 10:49 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I just added a command lie option to shutdown a running calibre instance. So now you can do this:

Code:
    calibre -s; sleep 4s; zip -R /path/to/plugin/zip/file.zip *; calibre
kovidgoyal is offline   Reply With Quote
Advert
Old 04-28-2011, 11:18 AM   #6
GRiker
Comparer of the Ephemeris
GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.
 
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
Kovid, would it be possible to use reload() if running in debug mode and calling a UserInterfacePlugin?

I've been using a variation on this approach that dynamically loads my actual plugin code from the zipped contents in the plugin. It depends upon some custom macros in my editor that modify both the unzipped copy of the plugin as well as the original plugin source (which needs to be rebuilt when exiting). Using this approach, I can simply rerun the plugin in place without losing context.

It seems like the concept of using reload() might be portable to the trunk.

G
GRiker is offline   Reply With Quote
Old 04-28-2011, 11:22 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Dynamic reloading is fraught with a lot of complications. This is because there may be references to the plugin class/an object instantiated from the class held in various places. The reload would have to invalidate an recreate all those references.
kovidgoyal is offline   Reply With Quote
Old 04-28-2011, 11:28 AM   #8
GRiker
Comparer of the Ephemeris
GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.
 
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
Yes, that makes sense for builtin plugins. But it seems that custom UI plugins wouldn't have active references to them in other parts of the code base. They tend to run modally, although there are some that don't (KiwiDude's Temp Marker comes to mind).

G
GRiker is offline   Reply With Quote
Old 04-28-2011, 11:36 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Well, the gui object holds a reference to the plugin object and the qaction built from the object.

While that could probably be managed, there' no guarantee that the plugin did not stick references to objects created in it anywhere else.

All in all, this is not a can of worms I want to open. With the -s switch, developing a plugin is now almost as easy as developing calibre source code (the only difference is an extra 4 second wait when launching calibre). I'm pretty happy with that.
kovidgoyal is offline   Reply With Quote
Old 04-28-2011, 12:09 PM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I should add that the zipplugin mechanism is reload friendly. So you can add code to your plugin that does

reload(module)

to have it reload some previously loaded module from your plugin.
kovidgoyal is offline   Reply With Quote
Old 04-29-2011, 02:59 AM   #11
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
Quote:
Originally Posted by kovidgoyal View Post
I should add that the zipplugin mechanism is reload friendly. So you can add code to your plugin that does

reload(module)

to have it reload some previously loaded module from your plugin.
Appreciate all the tips/changes that the thread started.

So using the reload(module) action could be temporarily tied directly into the plugin during the debugging phase as an action inside the plugin UI, correct? Based on the rest of the discussion it doesn't sound like something one would want to leave in the release version, but that could be a handy bit of code to comment/uncomment while making changes.
ldolse is offline   Reply With Quote
Old 04-29-2011, 10:18 AM   #12
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yes, that's the idea, put it in while developing and take it out later.
kovidgoyal is offline   Reply With Quote
Old 04-29-2011, 10:54 AM   #13
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,488
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Couldn't you set the reload code as a plugin tweak? This way you won't have to make changes for the release version.
user_none is offline   Reply With Quote
Old 04-29-2011, 10:57 AM   #14
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,839
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah, that would work.
kovidgoyal is offline   Reply With Quote
Old 11-04-2011, 05:36 AM   #15
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
I just made a sticky on this topic with links to any relevant data - the forum is generally the first place I always think to go on this topic when I'm getting back into plugin tweaking and it seems like I'm always seeking out this thread even when I could go to the docs. Anyway let me know if anything else useful on the topic should go into the sticky. I don't believe the reload tweak made it past the discussion phase.
ldolse 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
Reset Sony Device Interface plugin? NLight95 Devices 2 04-04-2011 06:40 PM
Writing an interface action plugin kiwidude Plugins 21 11-11-2010 04:11 PM
Device interface plugin - nook badmadbug Plugins 2 09-06-2010 11:03 AM
User Interface settings Ponderstibbons Calibre 1 09-05-2010 01:16 PM
iLiad User interface programming eth777 iRex Developer's Corner 3 12-23-2007 05:58 AM


All times are GMT -4. The time now is 07:39 PM.


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