kopia lustrzana https://github.com/inkstitch/inkstitch
deal with windows file copy permissions issues
rodzic
b842c4148b
commit
0e77c0d9a8
2
Makefile
2
Makefile
|
@ -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
|
# This gets the branch name or the name of the tag
|
||||||
VERSION:=$(TRAVIS_BRANCH)
|
VERSION:=$(TRAVIS_BRANCH)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
from os.path import realpath, dirname
|
from os.path import realpath, dirname
|
||||||
|
from glob import glob
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import socket
|
import socket
|
||||||
import errno
|
import errno
|
||||||
|
@ -12,7 +13,6 @@ import time
|
||||||
import logging
|
import logging
|
||||||
import wx
|
import wx
|
||||||
import inkex
|
import inkex
|
||||||
import shutil
|
|
||||||
from inkstitch.utils import guess_inkscape_config_path
|
from inkstitch.utils import guess_inkscape_config_path
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class InstallPalettesFrame(wx.Frame):
|
||||||
self.install_palettes()
|
self.install_palettes()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
wx.MessageDialog(self,
|
wx.MessageDialog(self,
|
||||||
_('Thread palette installation failed: ' + str(e)),
|
_('Thread palette installation failed') + ': \n' + traceback.format_exc(),
|
||||||
_('Installation Failed'),
|
_('Installation Failed'),
|
||||||
wx.OK).ShowModal()
|
wx.OK).ShowModal()
|
||||||
else:
|
else:
|
||||||
|
@ -81,21 +81,31 @@ class InstallPalettesFrame(wx.Frame):
|
||||||
|
|
||||||
def install_palettes(self):
|
def install_palettes(self):
|
||||||
path = self.path_input.GetValue()
|
path = self.path_input.GetValue()
|
||||||
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
|
|
||||||
palettes_dir = self.get_bundled_palettes_dir()
|
palettes_dir = self.get_bundled_palettes_dir()
|
||||||
|
self.copy_files(glob(os.path.join(palettes_dir, "*")), path)
|
||||||
for palette_file in os.listdir(palettes_dir):
|
|
||||||
shutil.copy(os.path.join(palettes_dir, palette_file), path)
|
|
||||||
|
|
||||||
def get_bundled_palettes_dir(self):
|
def get_bundled_palettes_dir(self):
|
||||||
if getattr(sys, 'frozen', None) is not None:
|
if getattr(sys, 'frozen', None) is not None:
|
||||||
return os.path.join(sys._MEIPASS, 'palettes')
|
return realpath(os.path.join(sys._MEIPASS, '..', 'palettes'))
|
||||||
else:
|
else:
|
||||||
return os.path.join(dirname(realpath(__file__)), 'palettes')
|
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):
|
class InstallPalettes(inkex.Effect):
|
||||||
def effect(self):
|
def effect(self):
|
||||||
app = wx.App()
|
app = wx.App()
|
|
@ -3,7 +3,12 @@ import sys
|
||||||
|
|
||||||
def guess_inkscape_config_path():
|
def guess_inkscape_config_path():
|
||||||
if getattr(sys, 'frozen', None):
|
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:
|
else:
|
||||||
path = expanduser("~/.config/inkscape")
|
path = expanduser("~/.config/inkscape")
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||||
<_name>Install thread manufacturer color palettes</_name>
|
<_name>Install thread manufacturer color palettes</_name>
|
||||||
<id>org.inkstitch.palettes</id>
|
<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>
|
<dependency type="executable" location="extensions">inkex.py</dependency>
|
||||||
<effect>
|
<effect>
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
|
@ -11,6 +11,6 @@
|
||||||
</effects-menu>
|
</effects-menu>
|
||||||
</effect>
|
</effect>
|
||||||
<script>
|
<script>
|
||||||
<command reldir="extensions" interpreter="python">embroider_install_palettes.py</command>
|
<command reldir="extensions" interpreter="python">embroider_palettes.py</command>
|
||||||
</script>
|
</script>
|
||||||
</inkscape-extension>
|
</inkscape-extension>
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PROJECT VERSION\n"
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -38,7 +38,7 @@ msgstr ""
|
||||||
msgid "Choose Inkscape palettes directory"
|
msgid "Choose Inkscape palettes directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Thread palette installation failed: "
|
msgid "Thread palette installation failed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Installation Failed"
|
msgid "Installation Failed"
|
||||||
|
|
|
@ -8,3 +8,5 @@ numpy
|
||||||
jinja2
|
jinja2
|
||||||
flask
|
flask
|
||||||
requests
|
requests
|
||||||
|
pywinutils; sys.platform == 'win32'
|
||||||
|
pywin32; sys.platform == 'win32'
|
||||||
|
|
Ładowanie…
Reference in New Issue