jespino / inkscape-export-layers

MIT License
40 stars 19 forks source link

Exporting on Windows fails with permission issue #9

Open mitchcurtis opened 6 years ago

mitchcurtis commented 6 years ago

I created a folder to export to:

C:\Users\Mitch\Documents\inkscape-layer-export-test

I exported via the extension, but got this error:

Traceback (most recent call last): File "export_layers.py", line 112, in _main() File "export_layers.py", line 108, in _main e.affect() File "C:\Program Files\Inkscape\share\extensions\inkex.py", line 283, in affect self.effect() File "export_layers.py", line 39, in effect self.export_layers(layer_dest_svg_path, show_layer_ids) File "export_layers.py", line 66, in export_layers doc.write(dest) File "src\lxml\lxml.etree.pyx", line 2033, in lxml.etree._ElementTree.write (src\lxml\lxml.etree.c:62933) File "src\lxml\serializer.pxi", line 512, in lxml.etree._tofilelike (src\lxml\lxml.etree.c:133361) File "src\lxml\serializer.pxi", line 571, in lxml.etree._create_output_buffer (src\lxml\lxml.etree.c:134025) File "src\lxml\serializer.pxi", line 560, in lxml.etree._create_output_buffer (src\lxml\lxml.etree.c:133825) IOError: [Errno 13] Permission denied

I checked the permissions on the file, and they looked fine.

The .svg file I used is here: drawing.zip

Nodragem commented 6 years ago

Same issue here with the exact same error.

mitchcurtis commented 6 years ago

I ended up fixing it like this:

https://github.com/mitchcurtis/inkscape-9-patch-export/commit/c5fd268f7dcdf4a6f9d0bead364d96af5c09dcf8

Nodragem commented 6 years ago

Hi @mitchcurtis,

I tried your code and it works pretty well! The only problem I 've got with it is that I needed to change the default path ~/ to the absolute path on my hard drive (e.g. D:\Gamedev\mygame\raw_assets\). I am on Windows.

Also, maybe you could rename your extension to something like Export Layers to PNG (ninepatch support). As for now, with the current name, I would have never thought your extension was answering my needs :)

Thanks a lot!

mitchcurtis commented 6 years ago

Hi. :)

The only problem I 've got with it is that I needed to change the default path ~/ to the absolute path on my hard drive (e.g. D:\Gamedev\mygame\raw_assets). I am on Windows.

What would you prefer happened? Your path should be remembered for the current Inkscape session at least, but I'm not sure what I can do about the default path.

Also, maybe you could rename your extension to something like Export Layers to PNG (ninepatch support). As for now, with the current name, I would have never thought your extension was answering my needs :)

I would, but it's for work, and the purpose of the extension is specifically to export 9-patch assets; exporting layers in general is just a bonus. :)

Nodragem commented 6 years ago

What I meant is that ~/ did not work on Windows, so I thought the extension was not working. So maybe yo could replace it with ./ or nothing or a button to browse the hard drive.

As for now, this is the only extension that exports layers on Windows. Maybe I could fork it and make few changes if you don't mind.

mitchcurtis commented 6 years ago

What I meant is that ~/ did not work on Windows, so I thought the extension was not working. So maybe yo could replace it with ./ or nothing

Would "./" work on all platforms? I'm not sure if there's a default path that will work on Windows, Mac and Linux.

Replacing it with nothing could work.

or a button to browse the hard drive.

This isn't possible currently; see: https://github.com/mitchcurtis/inkscape-9-patch-export#using-it

As for now, this is the only extension that exports layers on Windows. Maybe I could fork it and make few changes if you don't mind.

Sure, go for it. :) I'd also merge a pull request that removes the default path.

kpanas commented 6 years ago

Hi @jespino , was the problem fixed? I've downloaded the newest version and still cannot export (win7). Doesn't matter if I use the direct path or "./", nothing works.

Thanks!

mitchcurtis commented 6 years ago

@kpanas what was the error you got? And what was the path you used?

kpanas commented 6 years ago

@mitchcurtis I've used "D:\Dropbox\phd\gfx\vector" (the same directory that the .svg file is in). Here is the error (I cannot copy the text for some reason): image Thanks.

mitchcurtis commented 6 years ago

@kpanas I don't think the issue was ever fixed in this fork in that case. You can try using https://github.com/mitchcurtis/inkscape-9-patch-export instead.

dmitry-t commented 6 years ago

The problem is that on Windows a temporary file created for export needs cannot be opened again:

Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later).

So the solution is quite simple: pass file objects into internal functions instead of their names.

I will prepare a pull request if there are no objections. But I'll need help with testing the solution on platforms other than Windows.