Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-10-04 00:00:22 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-04 00:00:22 +0400
commitab8aa13b829c9a49b60294883613d6b4bf33f835 (patch)
tree9093a60747dffbd33747dfb50b36234f7f75b624 /release/scripts/ui/space_userpref.py
parent3e3e10668e501f516b0193763c753fbe9d2e7af4 (diff)
bugfix [#24087] Blender can not install add-ons unless running with root priviledges
now addon path is created using the same path functions and selecting where to save the startup.blend also made some minor changes to path handling funcs.
Diffstat (limited to 'release/scripts/ui/space_userpref.py')
-rw-r--r--release/scripts/ui/space_userpref.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py
index d15dc8934ca..f601b255510 100644
--- a/release/scripts/ui/space_userpref.py
+++ b/release/scripts/ui/space_userpref.py
@@ -1096,7 +1096,24 @@ class WM_OT_addon_install(bpy.types.Operator):
import zipfile
pyfile = self.filepath
- path_addons = bpy.utils.script_paths("addons")[-1]
+ # dont use bpy.utils.script_paths("addons") because we may not be able to write to it.
+ path_addons = bpy.utils.user_resource('SCRIPTS', 'addons')
+
+ # should never happen.
+ if not path_addons:
+ self.report({'WARNING'}, "Failed to get addons path\n")
+ return {'CANCELLED'}
+
+ # create path if not existing.
+ if not os.path.exists(path_addons):
+ try:
+ os.makedirs(path_addons)
+ except:
+ self.report({'WARNING'}, "Failed to create %r\n" % path_addons)
+
+ traceback.print_exc()
+ return {'CANCELLED'}
+
contents = set(os.listdir(path_addons))
#check to see if the file is in compressed format (.zip)
@@ -1115,7 +1132,7 @@ class WM_OT_addon_install(bpy.types.Operator):
path_dest = os.path.join(path_addons, os.path.basename(pyfile))
if os.path.exists(path_dest):
- self.report({'WARNING'}, "File already installed to '%s'\n" % path_dest)
+ self.report({'WARNING'}, "File already installed to %r\n" % path_dest)
return {'CANCELLED'}
#if not compressed file just copy into the addon path
@@ -1148,11 +1165,6 @@ class WM_OT_addon_install(bpy.types.Operator):
return {'FINISHED'}
def invoke(self, context, event):
- paths = bpy.utils.script_paths("addons")
- if not paths:
- self.report({'ERROR'}, "No 'addons' path could be found in " + str(bpy.utils.script_paths()))
- return {'CANCELLED'}
-
wm = context.window_manager
wm.add_fileselect(self)
return {'RUNNING_MODAL'}