Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-23-2015, 08:38 PM   #1
huang5307
Junior Member
huang5307 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2015
Device: Kindle Paper White 2
How to setup Python debug environment for Calibre Recipes

I am trying to develop a recipe. I want to setup a Python debug environment for Calibre Recipes (in Windows 8.1).

Firstly, I include Calibre lib to Python IDLE but still failed. Does anyone know to do that?
Quote:
>>> sys.path.insert(0, r"C:\Program Files\Calibre2\pylib.zip")
>>> from calibre.web.feeds.recipes import BasicNewsRecipe

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
from calibre.web.feeds.recipes import BasicNewsRecipe
File "site-packages\calibre\__init__.py", line 17, in <module>
File "site-packages\calibre\constants.py", line 203, in <module>
File "site-packages\calibre\constants.py", line 187, in __getitem__
File "site-packages\calibre\constants.py", line 162, in load_plugin
AttributeError: 'module' object has no attribute 'extensions_location'
>>>
huang5307 is offline   Reply With Quote
Old 03-23-2015, 09:10 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Just run calibre via "calibre-debug -g" to get debug output.

Alternatively, run "calibre-debug" to get an interactive python console that can access calibre's code. You cannot simply add the calibre source code, you need it to be properly installed which is difficult as it is a binary install. That is why calibre includes its own python console.

On linux, you can do a source install (for instance the repo packages) -- that would allow you to run bog-standard python debugging tools which can call on all of calibre's code.
eschwartz is offline   Reply With Quote
Advert
Old 03-24-2015, 03:18 AM   #3
huang5307
Junior Member
huang5307 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2015
Device: Kindle Paper White 2
Quote:
Originally Posted by eschwartz View Post
Just run calibre via "calibre-debug -g" to get debug output.

Alternatively, run "calibre-debug" to get an interactive python console that can access calibre's code. You cannot simply add the calibre source code, you need it to be properly installed which is difficult as it is a binary install. That is why calibre includes its own python console.

On linux, you can do a source install (for instance the repo packages) -- that would allow you to run bog-standard python debugging tools which can call on all of calibre's code.
actually, I try to do this is because I want to develop a recipe to handle soem web need username / password to access. Do you have any suggested documents for study.
huang5307 is offline   Reply With Quote
Old 03-24-2015, 07:16 AM   #4
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Take a look on the sticky posts at the top of this forum and calibre help for adding news: http://manual.calibre-ebook.com/news.html. There is an additional section at the end of this help called API documentation for recipes. Very useful. At least it is maybe a good idea to take a look to the command line interface help: http://manual.calibre-ebook.com/gene...cli-index.html

I use for recipe development two simple batch files in a working directory like "Your_Recipe" what runs the recipe via command line:

Your_Recipe.bat:

Code:
call Delete_Your_Recipe.bat
ebook-convert Your_Recipe.recipe .epub -vvv --debug-pipeline debug > Your_Recipe.log
And Delete_Your_Recipe.bat:

Code:
rmdir debug. /s /q
del Your_Recipe.epub
del Your_Recipe.log
The first batch file call a delete-batch for all previous created debug and log files if available and start then the recipe in debug modus and collect all screen printed information’s in a log file.
-vvv defines the level of verbosity
The second batch simply delete all created directories and files (debug- and log files)
Divingduck is offline   Reply With Quote
Old 03-24-2015, 08:56 AM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Kovid mentions on the development page in the user manual, his preferred debugging tool is liberal use of print statements in the source code. Why not try that?
eschwartz is offline   Reply With Quote
Advert
Old 03-24-2015, 10:11 AM   #6
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,609
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by eschwartz View Post
Kovid mentions on the development page in the user manual, his preferred debugging tool is liberal use of print statements in the source code. Why not try that?
That's the oldest (and usually most useful) way to debug a code.
Terisa de morgan is offline   Reply With Quote
Old 03-24-2015, 09:59 PM   #7
huang5307
Junior Member
huang5307 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2015
Device: Kindle Paper White 2
Quote:
Originally Posted by Terisa de morgan View Post
That's the oldest (and usually most useful) way to debug a code.
If there any way we can using IDE tools to develop recipe that would be very easy to understand the secret of Calibre recipes.
huang5307 is offline   Reply With Quote
Old 03-24-2015, 10:18 PM   #8
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
They aren't a big secret... anyway, what exactly do you want to see in the IDE that you cannot do with print statements? Considering recipes need to be run through ebook-convert anyway...
eschwartz is offline   Reply With Quote
Old 03-03-2016, 01:51 PM   #9
DanielBonnery
Member
DanielBonnery began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2016
Device: no
Hi,
I tried to follow
https://manual.calibre-ebook.com/develop.html.
But at some point I failed to test the recipe from the ide. Using the ebook-convert command is a pain. Thank you for the comments "Why don't you use print statements". It would be nice to have an answer to the original question for those who do not want to use print statements.

Bests,
Daniel

Last edited by DanielBonnery; 03-03-2016 at 02:33 PM.
DanielBonnery is offline   Reply With Quote
Old 03-03-2016, 02:35 PM   #10
DanielBonnery
Member
DanielBonnery began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jan 2016
Device: no
I found this:
http://jb-blog.readthedocs.org/en/la...-your-IDE.html
I followed the links but I could not have icu properly working...
I gave up at the end.
The print statements solution is really annoying, a button to test the recipe directly in the editor would be great. Now each time I test, I save and close the editor, run the fetch all news button, open the tasks windows, select the task, click to show log, close, reopen the editor ...

Last edited by DanielBonnery; 03-03-2016 at 08:39 PM.
DanielBonnery is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ctrl-Shft-R Debug vs calibre-debug -g JimmXinu Development 3 11-20-2014 09:57 AM
OSX Python environment DiapDealer Development 1 08-03-2014 11:10 PM
Running python recipes standonlone on hosted webserver oecherprinte Calibre 6 08-03-2011 04:30 PM
Windows batch file to test, debug and develop recipes euleralves Recipes 8 04-01-2011 04:22 PM
setup development environment JeffElkins Calibre 21 10-22-2008 03:25 PM


All times are GMT -4. The time now is 10:44 PM.


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