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 04-19-2016, 01:54 AM   #1
apprenticeharper
Apprentices Against DRM
apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.
 
apprenticeharper's Avatar
 
Posts: 46
Karma: 9787852
Join Date: Feb 2015
Location: UK
Device: Asus Laptop
Debug Mode and plugins

Can a plugin tell if it is running in debug mode?

I am having a problem with Broken Pipe on print statements when not in debug mode, and one solution would be to only execute the print statements in debug mode.

But I don't know whether a plugin can tell which mode calibre is in.
apprenticeharper is offline   Reply With Quote
Old 04-19-2016, 02:46 AM   #2
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I have also had some broken pipe errors reported on Macs recently. Most I tracked down to print statements I had left in the code. Kovid has checked in a change that hopefully will fix this.

In any case, use:

Code:
from calibre.constants import DEBUG
"DEBUG" will be true if calibre is in debug mode.

I also tend to use a function called "debug_print". That adds a time to the log and only prints in debug mode. This is defined in calibre/devices/usbms/driver.py but I will sometimes copy it locally so I can customise if for the plugin.
davidfor is offline   Reply With Quote
Old 04-19-2016, 07:12 AM   #3
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,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
As davidfor said, use the DEBUG constant. I dont know if my change will actually fix the problem, so it is best to be safe and only print debug output when in DEBUG mode.
kovidgoyal is offline   Reply With Quote
Old 04-29-2016, 01:59 AM   #4
apprenticeharper
Apprentices Against DRM
apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.apprenticeharper ought to be getting tired of karma fortunes by now.
 
apprenticeharper's Avatar
 
Posts: 46
Karma: 9787852
Join Date: Feb 2015
Location: UK
Device: Asus Laptop
Since I was already wrapping stdout and stderr with code to handle Unicode, I just added a try/pass to the print statement, and that seems to have done the trick.

I might use the DEBUG import on a later update. It would probably speed things up to a small extent.
apprenticeharper is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to start Calibre on Windows in debug mode hakan42 Development 9 04-10-2024 05:34 PM
Normal vs. Debug Mode rpspringuel Calibre 7 04-17-2016 09:03 PM
Impossible to quit Caibre in debug mode (2.2) PO40600 Calibre 4 09-08-2014 11:13 AM
Kindle Touch Debug Mode Access choclit Kindle Developer's Corner 2 11-22-2011 10:23 AM
Debug mode of HanLin v3 sang HanLin eBook 4 07-01-2009 04:00 PM


All times are GMT -4. The time now is 10:35 AM.


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