deal with windows file copy permissions issues

pull/154/head
Lex Neva 2018-04-25 20:55:17 -04:00
rodzic b842c4148b
commit 0e77c0d9a8
6 zmienionych plików z 33 dodań i 16 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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()

Wyświetl plik

@ -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")

Wyświetl plik

@ -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>

Wyświetl plik

@ -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"

Wyświetl plik

@ -8,3 +8,5 @@ numpy
jinja2
flask
requests
pywinutils; sys.platform == 'win32'
pywin32; sys.platform == 'win32'