![]() |
#1 |
Member
![]() Posts: 13
Karma: 10
Join Date: May 2025
Device: kindle
|
How to Get Instance of a Plugin?
How to Get Instance of a Plugin Using Calibre's Plugin Framework?
Is there a method like Source.get_plugin_by_name() to get a specific plugin's instance by its name (although I know it does not exist)? |
![]() |
![]() |
![]() |
#2 |
Member
![]() Posts: 13
Karma: 10
Join Date: May 2025
Device: kindle
|
Because I want to call plugins written by other authors in the plugin I am editing.
|
![]() |
![]() |
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,370
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Look at the functions in
calibre.customize.ui they give you access to all types of calibre plugins. |
![]() |
![]() |
![]() |
#4 | |
Member
![]() Posts: 13
Karma: 10
Join Date: May 2025
Device: kindle
|
Quote:
and still a little problem -- I am writing a InterfaceAction plugin, in which I want to call a Source plugin function. Now i have the source plugin instance Code:
from calibre.customize.ui import find_plugin plugin = find_plugin("plugin_name") Code:
def identify( self, log, result_queue, abort, title=None, authors=None, # {{{ identifiers={}, timeout=30) |
|
![]() |
![]() |
![]() |
#5 |
Member
![]() Posts: 13
Karma: 10
Join Date: May 2025
Device: kindle
|
Could this method cause initialization timing issues when one plugin depends on another?
|
![]() |
![]() |
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,370
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Dont call other plugins in your plugins initialize method and you wont have initialization issues. As for parameters to pass to identify() looka t how calibre itself calls the plugin identify methods, in sources/identify.py
|
![]() |
![]() |
![]() |
#7 | |
Member
![]() Posts: 13
Karma: 10
Join Date: May 2025
Device: kindle
|
Quote:
Code:
class Worker(Thread): def __init__(self, plugin, kwargs, abort): Thread.__init__(self) self.daemon = True self.plugin, self.kwargs, self.rq = plugin, kwargs, Queue() self.abort = abort self.buf = StringIO() self.log = create_log(self.buf) def run(self): start = time.time() try: self.plugin.identify(self.log, self.rq, self.abort, **self.kwargs) except Exception: self.log.exception('Plugin', self.plugin.name, 'failed') self.plugin.dl_time_spent = time.time() - start or is it possible to get the existing instance of "self.log"? |
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,370
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
from calibre.utils.logging import default_log
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
What Does This Mean??? | buyifan43 | Kindle Developer's Corner | 8 | 01-06-2025 11:17 PM |
PW2 dose anybody see this issue? | Jasonkindle | Kindle Developer's Corner | 2 | 12-12-2024 02:48 PM |
PW4 force the E-ink screen to refresh?? | kdusr | Kindle Developer's Corner | 7 | 09-20-2021 06:02 PM |
how to unbrick my Kindle? | yuwang | Kindle Developer's Corner | 10 | 09-26-2015 08:40 PM |
scanned PDF????? | xtdn20008 | enTourage eDGe | 6 | 06-18-2011 01:48 PM |