[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27174] trunk/blender/release/scripts/ui/ space_userpref.py: patch from Andy Braham with some modifications
Campbell Barton
ideasman42 at gmail.com
Sat Feb 27 23:36:37 CET 2010
Revision: 27174
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27174
Author: campbellbarton
Date: 2010-02-27 23:36:37 +0100 (Sat, 27 Feb 2010)
Log Message:
-----------
patch from Andy Braham with some modifications
extracts zipfiles when installing add-ons
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 2010-02-27 22:07:38 UTC (rev 27173)
+++ trunk/blender/release/scripts/ui/space_userpref.py 2010-02-27 22:36:37 UTC (rev 27174)
@@ -1471,25 +1471,38 @@
def execute(self, context):
import traceback
+ import zipfile
pyfile = self.properties.path
- paths = bpy.utils.script_paths("addons")
- path_dest = os.path.join(paths[-1], os.path.basename(pyfile))
+ path_addons = bpy.utils.script_paths("addons")[-1]
- if os.path.exists(path_dest):
- self.report({'WARNING'}, "File already installed to '%s'\n" % path_dest)
- return {'CANCELLED'}
+ #check to see if the file is in compressed format (.zip)
+ if zipfile.is_zipfile(pyfile):
+ try:
+ file_to_extract = zipfile.ZipFile(pyfile, 'r')
- if os.path.exists(path_dest):
- self.report({'WARNING'}, "File already installed to '%s'\n" % path_dest)
- return {'CANCELLED'}
+ #extract the file to "addons"
+ file_to_extract.extractall(path_addons)
+
+ except:
+ traceback.print_exc()
+ return {'CANCELLED'}
- try:
- shutil.copyfile(pyfile, path_dest)
- except:
- traceback.print_exc()
- return {'CANCELLED'}
+ else:
+ 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)
+ return {'CANCELLED'}
+
+ #if not compressed file just copy into the addon path
+ try:
+ shutil.copyfile(pyfile, path_dest)
+
+ except:
+ traceback.print_exc()
+ return {'CANCELLED'}
+
# TODO, should not be a warning.
# self.report({'WARNING'}, "File installed to '%s'\n" % path_dest)
return {'FINISHED'}
More information about the Bf-blender-cvs
mailing list