Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-08-2021, 09:45 AM   #1
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 93
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
RPDB is missing readline (calibre 5.10.1 under Windows 10)

I intend to learn learn python by writing a metadata source download.

I have written a script that download all the metadata from noosfere that I find important including resume, critics, cover's link, editor, serie, serie #, editor collection, editor collection #, original title... On Github: cal-noosfere... please be patient, I document in french, in English, sometimes both depending on the phase of the moon and I talk to my shadow...

In order to insert my script into calibre I need to make it an object that must be initiated by and must report to Calibre. Since I have no "feeling" about object programming, I decided to step through a working plugin via rpdp. That should be easy it is fully documented...

So I inserted at the begin of a well working plugin (kobo book) the following
Code:
    def identify(self, log, result_queue, abort, title=None, authors=None,
            identifiers={}, timeout=30):
        '''
        Note this method will retry without identifiers automatically if no
        match is found with identifiers.
        '''
        # lrp
        #
        from calibre.rpdb import set_trace
        set_trace()
        #
        # lrp
        matches = []
        log('identify - title: "%s" authors= "%s"'%(title, authors))

        # If we have a KoboBooks id then we do not need to fire a "search".
I started Calibre, started a metadata download with only kobo book enabled
and from a cmd terminal screen I issued

Code:
calibre-debug -c "from calibre.rpdb import cli; cli()"
the immediate answer was
Code:
Connecting to remote debugger on port 4444...
Connected to remote process
Traceback (most recent call last):
  File "runpy.py", line 194, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "site.py", line 82, in <module>
  File "site.py", line 77, in main
  File "site.py", line 49, in run_entry_point
  File "calibre\debug.py", line 270, in main
  File "<string>", line 1, in <module>
  File "calibre\rpdb.py", line 112, in cli
ModuleNotFoundError: No module named 'readline'
Some research on google seems to imply that this is a common problem under Windows 10 and solution would be to use pyreadline instead see https://stackoverflow.com/questions/...le-for-windows

Now, how do I install that into the "Calibre imbedded python"? I have not the intention to compile calibre, pip does not seems to be possible...

Another solution for me would be to use linux from my other slow computer, but that means to reinstall it on a larger disk. The space is so scarce that I cannot install python on it (I haven't dreamed to install Calibre yet)

Last but not least, after the __init__ to introduce the object to Calibre, is identify() the entry point to the plugin? If yes, may I guess that it is where I get the information about the book that needs metadata and the starting of the plugin work, while result_queue is where to send the metadata gathered???
lrpirlet is offline   Reply With Quote
Old 02-08-2021, 09:52 AM   #2
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,862
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can install pyreadline in your system python and have calibre pick it up by doing

import sys
sys.path.append('/path/to/folder/in/which/pyreadline/was/installed')

and yes identify is the main entry point for metadata download plugins.
kovidgoyal is online now   Reply With Quote
Old 02-08-2021, 04:20 PM   #3
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 93
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
Thanks kovidgoyal, using your suggestions, I managed to attach to the process... but could not 'talk' at all... the terminal was hanging, not answering any command ( I typed h for help and no h was echoed, no help came at all...)

I aborted the metadata download and the debug terminal then echoed the h and the few other debug command I tried... before claiming something about the fact that it was disconnected.

Humm, I think I will think another way to get the info I want...

Anyway, thanks for your advise, I did learn that python had a path (never though of it) and that modules could be placed system wide or, as in my case, in users space...
lrpirlet is offline   Reply With Quote
Old 02-08-2021, 09:17 PM   #4
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,862
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If I were you, I'd just use log.info() to print out the objects and they will apeear in the download log. I have developed all of calibre and learned touse python using just print()
kovidgoyal is online now   Reply With Quote
Old 02-09-2021, 04:04 AM   #5
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 93
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
Hi Kovidgoyal.

Thanks for the suggestion... I will start by uncommenting all the print() and log.info() leftover in the kobo book plugin. I am sure that will (start to) show the path taken by the code... Then I may force a crash with sys.exit() in an attempt to show the stack...

However, I just wanted to report that I could access (for a short time) a laptop running calibre (5.??) under Ubuntu... and NO python installed beside calibre (at least synaptic did not show it as installed)

It seems that the behavior of the rpdb is not much better... Granted, it connected first time without any hiccup but once connected, the only reaction was an echo of the character I typed (h for help then l for list)... when I aborted in Calibre, the terminal displayed the result of ls... (Seems that the l character was still in the terminal buffer and was passed to the shell; l is an alias of ls in Ubuntu...)

Something may be wrong with the debugger (?? maybe only under python 3.8 ??)... I am not quite sure nor do I want to follow the debugger path, but I think it may be worse reporting.

Again, thanks for your help and that beautiful piece of software.

Last edited by lrpirlet; 02-09-2021 at 04:08 AM.
lrpirlet is offline   Reply With Quote
Old 02-09-2021, 05:46 AM   #6
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,862
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Sorry I have never used rpdb myself, so I cant really help.
kovidgoyal is online now   Reply With Quote
Old 02-09-2021, 01:15 PM   #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,862
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
That should take care of it: https://github.com/kovidgoyal/calibr...4a331aca4e8381
kovidgoyal is online now   Reply With Quote
Old 02-12-2021, 09:47 AM   #8
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 93
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
Hi Kovidgoyal.

Thank you so much...

You say
Quote:
Sorry I have never used rpdb myself, so I cant really help.
and then you come with a working solution...

I'll be able in the coming days to follow the thread in the inner classes of calibre... So I can make use of it efficiently.

lrpirlet is offline   Reply With Quote
Old 02-12-2021, 10:34 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,862
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You are welcome, it basically ust required adjustment for python 3
kovidgoyal is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferences button missing in Windows 10 SecondoMe Calibre 2 07-30-2018 05:33 AM
Windows Calibre - normal Windows vs 64bit Windows midnightmaze Calibre 8 05-30-2015 07:16 AM
Calibre Metadata From Amazon Missing. What Am I Missing? BruticusBob Library Management 4 07-23-2013 08:43 PM
NUL file missing in windows mandolina Calibre 2 01-20-2012 03:44 PM
NUL file missing in windows mandolina Devices 2 01-20-2012 03:39 PM


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


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