Page MenuHome

Sapling generator requires root privileges when saving presets
Closed, ArchivedPublic

Description

System Information
Any system with blender installed by root

Blender Version
Broken: 2.76b 2015-11-03 10:56 f336fea

Short description of error
When trying to save presets for the sapling add-on, attempts are made to write to directories outside the current user's home directory. As a result, the preset is not saved, because of file permissions.

See also http://blender.stackexchange.com/questions/38172/error-while-exporting-preset-in-saplingadd-tree/41156#41156

Exact steps for others to reproduce the error
In object mode: Add/Curve/Add Tree, then try to "Export Preset"

Details

Type
Bug

Event Timeline

Torbjörn Rathsman (milasudril) raised the priority of this task from to Needs Triage by Developer.

@Aaron (Abpy) does this happen with your newer version of the addon?

hi, I confirm this bug & run some further tests.
I had thought this issue was fixed.
@Torbjörn Rathsman (milasudril) could you test this version please: https://developer.blender.org/T46559 & make comment there. It would be preferred to fix this issue in @Aaron (Abpy) version & update in one go.

This is also somewhat of a known issue on windows, the use of appdata folder requires admin permissions.
Thanks for your help..

So the problem is that windows will not write to the application folder?
Is the solution to write the preset somewhere else, or to just prevent saving if it does not work?

Sergey Sharybin (sergey) triaged this task as Normal priority.

While the patch might solve issue with particular addon, other addons will still be buggy? Also, the preset system itself should choose whether to use blender's application folder or user's config folder to store the presets.

@Campbell Barton (campbellbarton), can you comment on this?

Aaron (Abpy) added a comment.EditedNov 18 2015, 8:37 PM

Here is my solution.
user presets are saved to:

os.path.join(bpy.utils.script_path_user(), 'presets', 'operator', 'add_curve_sapling_3')

https://github.com/abpy/improved-sapling-tree-generator

@Aaron Levey (aaron) This solution works. However, it is not a good idea to test if a file exists first, and then open it. since the file can be created between the calls That's why I replaced open(...,'w') with open(...,'x'). Also I want the ability to overwrite my own presets, so perhaps the test can be removed.

I added an option to overwrite the file. It still uses os.path.exists though, because with the option to overwrite it doesn't make sense to use open(...,'x'), and it has to check that its not in the builtin presets.

(also, sorry its on github rather than a diff here. It would be a lot of extra work to make a diff between the blender version and mine)

@Aaron Levey (aaron), that will be fine. Hope the changes will go into the main branch soon

@Sergey Sharybin (sergey), this addon handles presets its self, other addons which use blender's preset system wont have issues.

@Aaron (Abpy), are your interested to take over maintaining the sapling generator bundled with Blender?

That, or I can fix the bug in master, and we can investigate including your changes later.
I just dont want the code to converge too far if we're going to eventually have to merge back.

@Campbell Barton (campbellbarton)
Yes, @Aaron (Abpy) the goal here is to replace current sapling addon entirely with the new updated version.

Any news here? If merging new work takes too much time let's at least fix the bug in master…

@Campbell Barton (campbellbarton) @Bastien Montagne (mont29)
Yes, @Aaron (Abpy) the goal here is to replace current sapling addon entirely with the new updated version.
What has happened here? I may take this over soon.

closing as archived.
If problem still exists in the new version (available in buildbot builds from tomorrow) please create a new task.
Note: Running Blender as Administrator on Windows fixes this problem.