diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | embroider_palettes.py (renamed from embroider_install_palettes.py) | 30 | ||||
| -rw-r--r-- | inkstitch/utils/inkscape.py | 7 | ||||
| -rw-r--r-- | inx/embroider_palettes.inx (renamed from inx/embroider_install_palettes.inx) | 4 | ||||
| -rw-r--r-- | messages.po | 4 | ||||
| -rw-r--r-- | requirements.txt | 2 |
6 files changed, 33 insertions, 16 deletions
@@ -1,4 +1,4 @@ -EXTENSIONS:=embroider embroider_params embroider_simulate embroider_print embroider_input embroider_install_palettes +EXTENSIONS:=embroider embroider_params embroider_simulate embroider_print embroider_input embroider_palettes # This gets the branch name or the name of the tag VERSION:=$(TRAVIS_BRANCH) diff --git a/embroider_install_palettes.py b/embroider_palettes.py index ba23fb2c..a3b59834 100644 --- a/embroider_install_palettes.py +++ b/embroider_palettes.py @@ -5,6 +5,7 @@ import sys import traceback import os from os.path import realpath, dirname +from glob import glob from threading import Thread import socket import errno @@ -12,7 +13,6 @@ import time import logging import wx import inkex -import shutil from inkstitch.utils import guess_inkscape_config_path @@ -68,7 +68,7 @@ class InstallPalettesFrame(wx.Frame): self.install_palettes() except Exception, e: wx.MessageDialog(self, - _('Thread palette installation failed: ' + str(e)), + _('Thread palette installation failed') + ': \n' + traceback.format_exc(), _('Installation Failed'), wx.OK).ShowModal() else: @@ -81,21 +81,31 @@ class InstallPalettesFrame(wx.Frame): def install_palettes(self): path = self.path_input.GetValue() - - if not os.path.exists(path): - os.makedirs(path) - palettes_dir = self.get_bundled_palettes_dir() - - for palette_file in os.listdir(palettes_dir): - shutil.copy(os.path.join(palettes_dir, palette_file), path) + self.copy_files(glob(os.path.join(palettes_dir, "*")), path) def get_bundled_palettes_dir(self): if getattr(sys, 'frozen', None) is not None: - return os.path.join(sys._MEIPASS, 'palettes') + return realpath(os.path.join(sys._MEIPASS, '..', 'palettes')) else: return os.path.join(dirname(realpath(__file__)), 'palettes') + if (sys.platform == "win32"): + # If we try to just use shutil.copy it says the operation requires elevation. + def copy_files(self, files, dest): + import winutils + + winutils.copy(files, dest) + else: + def copy_files(self, files, dest): + import shutil + + if not os.path.exists(dest): + os.makedirs(dest) + + for palette_file in files: + shutil.copy(palette_file, dest) + class InstallPalettes(inkex.Effect): def effect(self): app = wx.App() diff --git a/inkstitch/utils/inkscape.py b/inkstitch/utils/inkscape.py index 4aba1bad..2d0298bc 100644 --- a/inkstitch/utils/inkscape.py +++ b/inkstitch/utils/inkscape.py @@ -3,7 +3,12 @@ import sys def guess_inkscape_config_path(): if getattr(sys, 'frozen', None): - path = realpath(path_join(sys._MEIPASS, "..")) + path = realpath(path_join(sys._MEIPASS, "..", "..", "..")) + if sys.platform == "win32": + import win32api + + # This expands ugly things like EXTENS~1 + path = win32api.GetLongPathName(path) else: path = expanduser("~/.config/inkscape") diff --git a/inx/embroider_install_palettes.inx b/inx/embroider_palettes.inx index 063d6670..47ff6cf3 100644 --- a/inx/embroider_install_palettes.inx +++ b/inx/embroider_palettes.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Install thread manufacturer color palettes</_name> <id>org.inkstitch.palettes</id> - <dependency type="executable" location="extensions">embroider_install_palettes.py</dependency> + <dependency type="executable" location="extensions">embroider_palettes.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <effect> <object-type>all</object-type> @@ -11,6 +11,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">embroider_install_palettes.py</command> + <command reldir="extensions" interpreter="python">embroider_palettes.py</command> </script> </inkscape-extension> diff --git a/messages.po b/messages.po index 192ff456..956d1986 100644 --- a/messages.po +++ b/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-04-28 17:58-0400\n" +"POT-Creation-Date: 2018-04-28 17:59-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -38,7 +38,7 @@ msgstr "" msgid "Choose Inkscape palettes directory" msgstr "" -msgid "Thread palette installation failed: " +msgid "Thread palette installation failed" msgstr "" msgid "Installation Failed" diff --git a/requirements.txt b/requirements.txt index 70baadc6..7771f0d1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,5 @@ numpy jinja2 flask requests +pywinutils; sys.platform == 'win32' +pywin32; sys.platform == 'win32' |
