2021-03-12 04:17:19 +00:00
|
|
|
# Authors: see git history
|
|
|
|
#
|
|
|
|
# Copyright (c) 2010 Authors
|
|
|
|
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
|
|
|
|
|
2019-04-11 03:37:16 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
2019-04-11 04:03:23 +00:00
|
|
|
import sys
|
2019-04-11 03:37:16 +00:00
|
|
|
|
|
|
|
from ..utils import get_bundled_dir
|
|
|
|
|
|
|
|
app_process = None
|
|
|
|
|
|
|
|
|
|
|
|
def open_url(url):
|
|
|
|
global app
|
|
|
|
|
2019-04-23 01:42:17 +00:00
|
|
|
command = []
|
|
|
|
cwd = None
|
2019-04-18 01:48:44 +00:00
|
|
|
|
2019-04-11 04:03:23 +00:00
|
|
|
if getattr(sys, 'frozen', None) is not None:
|
|
|
|
electron_path = os.path.join(get_bundled_dir("electron"), "inkstitch-gui")
|
|
|
|
|
2019-04-12 21:45:57 +00:00
|
|
|
if sys.platform == "darwin":
|
|
|
|
electron_path += ".app/Contents/MacOS/inkstitch-gui"
|
2019-11-11 22:59:51 +00:00
|
|
|
command = ["open", "-W", "-a", electron_path, "--args", url]
|
2019-04-12 21:45:57 +00:00
|
|
|
else:
|
2019-04-23 01:42:17 +00:00
|
|
|
command = [electron_path, url]
|
2019-04-11 05:00:28 +00:00
|
|
|
else:
|
2019-04-12 21:45:57 +00:00
|
|
|
# if we're not running in a pyinstaller bundle, run electron directly
|
2019-04-23 01:42:17 +00:00
|
|
|
command = ["yarn", "dev", url]
|
|
|
|
cwd = get_bundled_dir("electron")
|
2019-04-11 03:37:16 +00:00
|
|
|
|
2019-04-23 01:42:17 +00:00
|
|
|
# Any output on stdout will crash inkscape.
|
2021-03-04 17:40:53 +00:00
|
|
|
with open(os.devnull, 'w') as null:
|
|
|
|
return subprocess.Popen(command, cwd=cwd, stdout=null)
|