boxes_proxy (for Inkscape): Use temp file

Resolves permission issues when trying to place files into system extension
directory.

Resolves: #516
This commit is contained in:
Florian Festi 2023-02-08 22:52:40 +01:00
parent 455f5ae69a
commit 8b961797f9
1 changed files with 3 additions and 4 deletions

View File

@ -16,6 +16,7 @@ import inkex
import sys import sys
import os import os
from lxml import etree from lxml import etree
import tempfile
class boxesPyWrapper(inkex.GenerateExtension): class boxesPyWrapper(inkex.GenerateExtension):
@ -31,9 +32,7 @@ class boxesPyWrapper(inkex.GenerateExtension):
pass #ignore duplicate id arg pass #ignore duplicate id arg
def generate(self): def generate(self):
box_file = "box.svg" f, box_file = tempfile.mkstemp(".svg", "boxes.py-inkscape")
if os.path.exists(box_file):
os.remove(box_file) #remove previously generated box file at the beginning
cmd = "boxes" #boxes.exe in this local dir (or if present in %PATH%), or boxes from $PATH in linux cmd = "boxes" #boxes.exe in this local dir (or if present in %PATH%), or boxes from $PATH in linux
for arg in vars(self.options): for arg in vars(self.options):
@ -74,4 +73,4 @@ class boxesPyWrapper(inkex.GenerateExtension):
return group return group
if __name__ == '__main__': if __name__ == '__main__':
boxesPyWrapper().run() boxesPyWrapper().run()