04-19-2016, 01:54 AM | #1 |
Apprentices Against DRM
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. |
04-19-2016, 02:46 AM | #2 |
Grand Sorcerer
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 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. |
04-19-2016, 07:12 AM | #3 |
creator of calibre
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.
|
04-29-2016, 01:59 AM | #4 |
Apprentices Against DRM
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. |
|
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 |