From 0bddbb67ad852dabb08441a47156351f035b53ed Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 14 May 2017 21:55:59 +0530 Subject: [PATCH] Allow running calibre in debug mode via an environment variable --- src/calibre/constants.py | 2 +- src/calibre/debug.py | 1 - src/calibre/gui_launch.py | 4 ++++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 7ae4491ff0..07dc7d1533 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -87,7 +87,7 @@ else: filesystem_encoding = 'utf-8' -DEBUG = False +DEBUG = b'CALIBRE_DEBUG' in os.environ def debug(): diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 2838d0a3e7..8600638274 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -250,7 +250,6 @@ def main(args=sys.argv): opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui_launch import calibre - print_basic_debug_info() calibre(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) diff --git a/src/calibre/gui_launch.py b/src/calibre/gui_launch.py index ba6d2a3eed..16f54916d4 100644 --- a/src/calibre/gui_launch.py +++ b/src/calibre/gui_launch.py @@ -63,6 +63,10 @@ def register_with_default_programs(): def calibre(args=sys.argv): + from calibre.constants import DEBUG + if DEBUG: + from calibre.debug import print_basic_debug_info + print_basic_debug_info() detach_gui() init_dbus() with register_with_default_programs():