From 9ccf2f552be246f7912e9dc923f8da8ae47fe544 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 10 Apr 2019 23:37:16 -0400 Subject: switch print pdf gui to electron --- lib/gui/electron.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/gui/electron.py (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py new file mode 100644 index 00000000..cad86a16 --- /dev/null +++ b/lib/gui/electron.py @@ -0,0 +1,16 @@ +import os +import subprocess + +from ..utils import get_bundled_dir + + +app_process = None + + +def open_url(url): + global app + + electron_path = os.path.join(get_bundled_dir("electron"), "out", "inkstitch-linux-x64", "inkstitch-gui") + app_process = subprocess.Popen([electron_path, url]) + + return app_process -- cgit v1.2.3 From d52dc8d5fc80fad645718805ebf6ec297ace8a44 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 11 Apr 2019 00:03:23 -0400 Subject: fix electron path --- lib/gui/electron.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index cad86a16..d3547c34 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -1,5 +1,6 @@ import os import subprocess +import sys from ..utils import get_bundled_dir @@ -10,7 +11,19 @@ app_process = None def open_url(url): global app - electron_path = os.path.join(get_bundled_dir("electron"), "out", "inkstitch-linux-x64", "inkstitch-gui") + if getattr(sys, 'frozen', None) is not None: + electron_path = os.path.join(get_bundled_dir("electron"), "inkstitch-gui") + else: + # It's a bit trickier to find the electron app in a development environment. + base_dir = get_bundled_dir("electron") + + try: + package_dir = os.listdir(os.path.join(base_dir, "out"))[0] + except (OSError, IndexError): + raise Exception("Electron app not found. Be sure to run 'npm install; npm run package' in %s." % base_dir) + + electron_path = os.path.join(base_dir, "out", package_dir, "inkstitch-gui") + app_process = subprocess.Popen([electron_path, url]) return app_process -- cgit v1.2.3 From 28ffc8692c30ce2db98b70b7752927758ed8f772 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 11 Apr 2019 01:00:28 -0400 Subject: launch electron properly on macos --- lib/gui/electron.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index d3547c34..6a31abe1 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -24,6 +24,10 @@ def open_url(url): electron_path = os.path.join(base_dir, "out", package_dir, "inkstitch-gui") - app_process = subprocess.Popen([electron_path, url]) + if sys.platform == "darwin": + electron_path += ".app/Contents/MacOS/inkstitch-gui" + app_process = subprocess.Popen(["open", "-a", electron_path, "--args", url]) + else: + app_process = subprocess.Popen([electron_path, url]) return app_process -- cgit v1.2.3 From 0d54c828d0477db8666ff24d451591d9f7fdcf57 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 12 Apr 2019 01:41:14 -0400 Subject: use docker for windows --- lib/gui/electron.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index 6a31abe1..4ecc37bf 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -1,3 +1,4 @@ +from glob import glob import os import subprocess import sys @@ -16,13 +17,12 @@ def open_url(url): else: # It's a bit trickier to find the electron app in a development environment. base_dir = get_bundled_dir("electron") + package_dir = glob(os.path.join(base_dir, 'dist', '*-unpacked')) - try: - package_dir = os.listdir(os.path.join(base_dir, "out"))[0] - except (OSError, IndexError): - raise Exception("Electron app not found. Be sure to run 'npm install; npm run package' in %s." % base_dir) + if not package_dir: + raise Exception("Electron app not found. Be sure to run 'yarn; yarn dist' in %s." % base_dir) - electron_path = os.path.join(base_dir, "out", package_dir, "inkstitch-gui") + electron_path = os.path.join(base_dir, package_dir, "inkstitch-gui") if sys.platform == "darwin": electron_path += ".app/Contents/MacOS/inkstitch-gui" -- cgit v1.2.3 From 5b5cde330fd21289fcdce7f43d37c54b7cc73310 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 12 Apr 2019 16:48:25 -0400 Subject: fix dev path --- lib/gui/electron.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index 4ecc37bf..ced3ad66 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -17,9 +17,10 @@ def open_url(url): else: # It's a bit trickier to find the electron app in a development environment. base_dir = get_bundled_dir("electron") - package_dir = glob(os.path.join(base_dir, 'dist', '*-unpacked')) - if not package_dir: + try: + package_dir = glob(os.path.join(base_dir, 'dist', '*-unpacked'))[0] + except IndexError: raise Exception("Electron app not found. Be sure to run 'yarn; yarn dist' in %s." % base_dir) electron_path = os.path.join(base_dir, package_dir, "inkstitch-gui") -- cgit v1.2.3 From 9b2a47136b34a4b9cfcc42282a39fdd909e9f8af Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 12 Apr 2019 17:45:57 -0400 Subject: enable print button --- lib/gui/electron.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index ced3ad66..f1bdeb61 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -1,4 +1,3 @@ -from glob import glob import os import subprocess import sys @@ -14,21 +13,14 @@ def open_url(url): if getattr(sys, 'frozen', None) is not None: electron_path = os.path.join(get_bundled_dir("electron"), "inkstitch-gui") - else: - # It's a bit trickier to find the electron app in a development environment. - base_dir = get_bundled_dir("electron") - - try: - package_dir = glob(os.path.join(base_dir, 'dist', '*-unpacked'))[0] - except IndexError: - raise Exception("Electron app not found. Be sure to run 'yarn; yarn dist' in %s." % base_dir) - - electron_path = os.path.join(base_dir, package_dir, "inkstitch-gui") - if sys.platform == "darwin": - electron_path += ".app/Contents/MacOS/inkstitch-gui" - app_process = subprocess.Popen(["open", "-a", electron_path, "--args", url]) + if sys.platform == "darwin": + electron_path += ".app/Contents/MacOS/inkstitch-gui" + subprocess.Popen(["open", "-a", electron_path, "--args", url]) + else: + app_process = subprocess.Popen([electron_path, url]) else: - app_process = subprocess.Popen([electron_path, url]) + # if we're not running in a pyinstaller bundle, run electron directly + app_process = subprocess.Popen(["yarn", "dev", url], cwd=get_bundled_dir("electron")) return app_process -- cgit v1.2.3 From 67027f07046aecc9e45785e077ad7ee70b365c0c Mon Sep 17 00:00:00 2001 From: Kate Murphy Date: Wed, 17 Apr 2019 21:48:44 -0400 Subject: Fix crashed caused by Inkscape reading message from stdout --- lib/gui/electron.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index f1bdeb61..8bc0bcef 100644 --- a/lib/gui/electron.py +++ b/lib/gui/electron.py @@ -11,16 +11,19 @@ app_process = None def open_url(url): global app + # Any output on stdout will crash inkscape. + null = open(os.devnull, 'w') + 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]) + subprocess.Popen(["open", "-a", electron_path, "--args", url], stdout=null) else: app_process = subprocess.Popen([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")) + app_process = subprocess.Popen(["yarn", "dev", url], cwd=get_bundled_dir("electron"), stdout=null) return app_process -- cgit v1.2.3 From a3b7d8eb421d6e909c374c92560cfeec230bba69 Mon Sep 17 00:00:00 2001 From: katee Date: Mon, 22 Apr 2019 21:42:17 -0400 Subject: Refactor electron to always pipe stdout to /dev/null --- lib/gui/electron.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/gui/electron.py') diff --git a/lib/gui/electron.py b/lib/gui/electron.py index 8bc0bcef..6bff15aa 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) -- cgit v1.2.3