From ef6f6580df6e8fbce913eecc1fe7e0f8caf1315b Mon Sep 17 00:00:00 2001 From: rejbasket <39080670+rejbasket@users.noreply.github.com> Date: Mon, 22 May 2023 22:33:19 +0200 Subject: Update electron version to v14.2.9 (#2214) Authored-by: rejbasket Co-authored-by: Kaalleen Co-authored-by: Lex Neva --- lib/extensions/install.py | 50 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'lib/extensions/install.py') diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 62cfde73..501694ed 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -4,18 +4,48 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. from .base import InkstitchExtension -from ..api import APIServer -from ..gui import open_url +import os +import sys +from glob import glob +from ..utils import get_bundled_dir, guess_inkscape_config_path +from inkex import errormsg +from ..i18n import _ class Install(InkstitchExtension): - def __init__(self): - InkstitchExtension.__init__(self) + def __init__(self, *args, **kwargs): + InkstitchExtension.__init__(self, *args, **kwargs) def effect(self): - api_server = APIServer(self) - port = api_server.start_server() - electron = open_url("/install?port=%d" % port) - electron.wait() - api_server.stop() - api_server.join() + path = os.path.join(guess_inkscape_config_path(), 'palettes') + src_dir = get_bundled_dir('palettes') + try: + copy_files(glob(os.path.join(src_dir, "*")), path) + errormsg(_("Successfully installed color palettes for Inkscape.\n\n" + "Please restart Inkscape.")) + except IOError: + errormsg(_("Could not install color palettes. Please file an issue on " + "https://github.com/inkstitch/inkstitch/issues")) + + +if sys.platform == "win32": + # If we try to just use shutil.copy it says the operation requires elevation. + def copy_files(files, dest): + import pythoncom + import winutils + + pythoncom.CoInitialize() + + if not os.path.exists(dest): + os.makedirs(dest) + + winutils.copy(files, dest) +else: + def copy_files(files, dest): + import shutil + + if not os.path.exists(dest): + os.makedirs(dest) + + for palette_file in files: + shutil.copy(palette_file, dest) -- cgit v1.2.3