From a3b7d8eb421d6e909c374c92560cfeec230bba69 Mon Sep 17 00:00:00 2001 From: katee Date: Mon, 22 Apr 2019 21:42:17 -0400 Subject: [PATCH] Refactor electron to always pipe stdout to /dev/null --- lib/gui/electron.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/gui/electron.py b/lib/gui/electron.py index 8bc0bcef1..6bff15aab 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -11,19 +11,22 @@ app_process = None def open_url(url): global app - # Any output on stdout will crash inkscape. - null = open(os.devnull, 'w') + command = [] + cwd = None if getattr(sys, 'frozen', None) is not None: electron_path = os.path.join(get_bundled_dir("electron"), "inkstitch-gui") if sys.platform == "darwin": electron_path += ".app/Contents/MacOS/inkstitch-gui" - subprocess.Popen(["open", "-a", electron_path, "--args", url], stdout=null) + command = ["open", "-a", electron_path, "--args", url] else: - app_process = subprocess.Popen([electron_path, url]) + command = [electron_path, url] else: # if we're not running in a pyinstaller bundle, run electron directly - app_process = subprocess.Popen(["yarn", "dev", url], cwd=get_bundled_dir("electron"), stdout=null) + command = ["yarn", "dev", url] + cwd = get_bundled_dir("electron") - return app_process + # Any output on stdout will crash inkscape. + null = open(os.devnull, 'w') + return subprocess.Popen(command, cwd=cwd, stdout=null)