From 49c9cea7b06ef7f86e480d54c0499fb2a4f5a6c6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 17 Dec 2010 10:27:37 -0700 Subject: [PATCH] Fix debug process launching on windows --- src/calibre/gui2/main.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index d8316cbf68..371c4df701 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -254,6 +254,7 @@ def run_in_debug_mode(logpath=None): e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0] import tempfile, subprocess fd, logpath = tempfile.mkstemp('.txt') + os.close(fd) if hasattr(sys, 'frameworks_dir'): base = os.path.dirname(sys.frameworks_dir) @@ -265,8 +266,13 @@ def run_in_debug_mode(logpath=None): base, ext = os.path.splitext(e) exe = base + '-debug' + ext print 'Starting debug executable:', exe - subprocess.Popen([exe, '--gui-debug', logpath], stdout=fd, stderr=fd) - time.sleep(1) # Give subprocess a change to launch, before fd is closed + creationflags = 0 + if iswindows: + import win32process + creationflags = win32process.CREATE_NO_WINDOW + subprocess.Popen([exe, '--gui-debug', logpath], stdout=open(logpath, 'w'), + stderr=subprocess.STDOUT, stdin=open(os.devnull, 'r'), + creationflags=creationflags) def run_gui(opts, args, actions, listener, app, gui_debug=None): initialize_file_icon_provider() @@ -300,7 +306,13 @@ def run_gui(opts, args, actions, listener, app, gui_debug=None): if runner.main.gui_debug is not None: e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0] import subprocess - subprocess.Popen([e, '--show-gui-debug', runner.main.gui_debug]) + creationflags = 0 + 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')) return ret def cant_start(msg=_('If you are sure it is not running')+', ',