From 17f7b8a14f5907d5c0244c2bf42c36913fc31546 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 Aug 2014 09:51:23 +0530 Subject: [PATCH] Simplify code to show GUI debug log Fixes regression caused by Qt 5 behavior change that prevented the debug log from being displayed in linux. --- src/calibre/debug.py | 15 --------------- src/calibre/gui2/main.py | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 041cbd0c19..5384e28b7c 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -41,9 +41,6 @@ Everything after the -- is passed to the script. help=_('Run the GUI with a debug console, logging to the' ' specified path. For internal use only, use the -g' ' option to run the GUI in debug mode')) - parser.add_option('--show-gui-debug', default=None, - help=_('Display the specified log file. For internal use' - ' only.')) parser.add_option('-w', '--viewer', default=False, action='store_true', help=_('Run the ebook viewer in debug mode')) parser.add_option('--paths', default=False, action='store_true', @@ -220,18 +217,6 @@ def main(args=sys.argv): main(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) - elif opts.show_gui_debug: - import time, re - time.sleep(1) - from calibre.gui2 import open_local_file - if iswindows: - with open(opts.show_gui_debug, 'r+b') as f: - raw = f.read() - raw = re.sub('(?' -import sys, os, time, socket, traceback +import sys, os, time, socket, traceback, re from functools import partial import apsw @@ -349,14 +349,16 @@ def run_gui(opts, args, listener, app, gui_debug=None): pass if getattr(runner.main, 'gui_debug', None) is not None: e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0] - import subprocess - creationflags = 0 + debugfile = runner.main.gui_debug + from calibre.gui2 import open_local_file if iswindows: - import win32process - creationflags = win32process.CREATE_NO_WINDOW - subprocess.Popen([e, '--show-gui-debug', runner.main.gui_debug], - creationflags=creationflags, stdout=open(os.devnull, 'w'), - stderr=subprocess.PIPE, stdin=open(os.devnull, 'r')) + with open(debugfile, 'r+b') as f: + raw = f.read() + raw = re.sub(b'(?