mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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.
This commit is contained in:
parent
736a16d335
commit
17f7b8a14f
@ -41,9 +41,6 @@ Everything after the -- is passed to the script.
|
|||||||
help=_('Run the GUI with a debug console, logging to the'
|
help=_('Run the GUI with a debug console, logging to the'
|
||||||
' specified path. For internal use only, use the -g'
|
' specified path. For internal use only, use the -g'
|
||||||
' option to run the GUI in debug mode'))
|
' 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',
|
parser.add_option('-w', '--viewer', default=False, action='store_true',
|
||||||
help=_('Run the ebook viewer in debug mode'))
|
help=_('Run the ebook viewer in debug mode'))
|
||||||
parser.add_option('--paths', default=False, action='store_true',
|
parser.add_option('--paths', default=False, action='store_true',
|
||||||
@ -220,18 +217,6 @@ def main(args=sys.argv):
|
|||||||
main(['calibre'])
|
main(['calibre'])
|
||||||
elif opts.gui_debug is not None:
|
elif opts.gui_debug is not None:
|
||||||
run_debug_gui(opts.gui_debug)
|
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('(?<!\r)\n', '\r\n', raw)
|
|
||||||
f.seek(0)
|
|
||||||
f.truncate()
|
|
||||||
f.write(raw)
|
|
||||||
open_local_file(opts.show_gui_debug)
|
|
||||||
elif opts.viewer:
|
elif opts.viewer:
|
||||||
from calibre.gui2.viewer.main import main
|
from calibre.gui2.viewer.main import main
|
||||||
main(['ebook-viewer'] + args[1:])
|
main(['ebook-viewer'] + args[1:])
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import sys, os, time, socket, traceback
|
import sys, os, time, socket, traceback, re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import apsw
|
import apsw
|
||||||
@ -349,14 +349,16 @@ def run_gui(opts, args, listener, app, gui_debug=None):
|
|||||||
pass
|
pass
|
||||||
if getattr(runner.main, 'gui_debug', None) is not None:
|
if getattr(runner.main, 'gui_debug', None) is not None:
|
||||||
e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0]
|
e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0]
|
||||||
import subprocess
|
debugfile = runner.main.gui_debug
|
||||||
creationflags = 0
|
from calibre.gui2 import open_local_file
|
||||||
if iswindows:
|
if iswindows:
|
||||||
import win32process
|
with open(debugfile, 'r+b') as f:
|
||||||
creationflags = win32process.CREATE_NO_WINDOW
|
raw = f.read()
|
||||||
subprocess.Popen([e, '--show-gui-debug', runner.main.gui_debug],
|
raw = re.sub(b'(?<!\r)\n', b'\r\n', raw)
|
||||||
creationflags=creationflags, stdout=open(os.devnull, 'w'),
|
f.seek(0)
|
||||||
stderr=subprocess.PIPE, stdin=open(os.devnull, 'r'))
|
f.truncate()
|
||||||
|
f.write(raw)
|
||||||
|
open_local_file(debugfile)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def cant_start(msg=_('If you are sure it is not running')+', ',
|
def cant_start(msg=_('If you are sure it is not running')+', ',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user