[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34598] trunk/blender/release/scripts/ui/ space_userpref.py: bugfix [#25767] Addons cannot be upgraded through the UI
Campbell Barton
ideasman42 at gmail.com
Tue Feb 1 07:48:20 CET 2011
Revision: 34598
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34598
Author: campbellbarton
Date: 2011-02-01 06:48:19 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
bugfix [#25767] Addons cannot be upgraded through the UI
added option to overwrite.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_userpref.py
Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py 2011-02-01 05:15:32 UTC (rev 34597)
+++ trunk/blender/release/scripts/ui/space_userpref.py 2011-02-01 06:48:19 UTC (rev 34598)
@@ -1150,13 +1150,27 @@
bl_idname = "wm.addon_install"
bl_label = "Install Add-On..."
- module = StringProperty(name="Module", description="Module name of the addon to disable")
+ overwrite = BoolProperty(name="Overwrite", description="Remove existing addons with the same ID", default=True)
filepath = StringProperty(name="File Path", description="File path to write file to")
filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
filter_glob = StringProperty(default="*.py;*.zip", options={'HIDDEN'})
+ @staticmethod
+ def _module_remove(path_addons, module):
+ module = os.path.splitext(module)[0]
+ for f in os.listdir(path_addons):
+ f_base = os.path.splitext(f)[0]
+ if f_base == module:
+ f_full = os.path.join(path_addons, f)
+
+ if os.path.isdir(f_full):
+ os.rmdir(f_full)
+ else:
+ os.remove(f_full)
+
+
def execute(self, context):
import traceback
import zipfile
@@ -1175,10 +1189,22 @@
if zipfile.is_zipfile(pyfile):
try:
file_to_extract = zipfile.ZipFile(pyfile, 'r')
+ except:
+ traceback.print_exc()
+ return {'CANCELLED'}
- #extract the file to "addons"
+ if self.overwrite:
+ for f in file_to_extract.namelist():
+ __class__._module_remove(path_addons, f)
+ else:
+ for f in file_to_extract.namelist():
+ path_dest = os.path.join(path_addons, os.path.basename(f))
+ if os.path.exists(path_dest):
+ self.report({'WARNING'}, "File already installed to %r\n" % path_dest)
+ return {'CANCELLED'}
+
+ try: # extract the file to "addons"
file_to_extract.extractall(path_addons)
-
except:
traceback.print_exc()
return {'CANCELLED'}
@@ -1186,9 +1212,12 @@
else:
path_dest = os.path.join(path_addons, os.path.basename(pyfile))
- if os.path.exists(path_dest):
+ if self.overwrite:
+ __class__._module_remove(path_addons, os.path.basename(pyfile))
+ elif os.path.exists(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
try:
More information about the Bf-blender-cvs
mailing list