[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39177] trunk/blender/release/scripts/ startup/bl_ui/space_userpref_keymap.py: report error on installign keymaps rather then raising an exception.

Campbell Barton ideasman42 at gmail.com
Mon Aug 8 11:09:44 CEST 2011


Revision: 39177
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39177
Author:   campbellbarton
Date:     2011-08-08 09:09:44 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
report error on installign keymaps rather then raising an exception.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py	2011-08-08 09:01:09 UTC (rev 39176)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py	2011-08-08 09:09:44 UTC (rev 39177)
@@ -542,24 +542,24 @@
     def execute(self, context):
         from os.path import basename
         import shutil
+
         if not self.filepath:
-            raise Exception("Filepath not set")
+            self.report({'ERROR'}, "Filepath not set")
+            return {'CANCELLED'}
 
-        # simply check we can open
-        f = open(self.filepath, "r")
-        if not f:
-            raise Exception("Could not open file")
-        f.close()
-
         config_name = basename(self.filepath)
 
         path = bpy.utils.user_resource('SCRIPTS', os.path.join("presets", "keyconfig"), create=True)
         path = os.path.join(path, config_name)
 
-        if self.keep_original:
-            shutil.copy(self.filepath, path)
-        else:
-            shutil.move(self.filepath, path)
+        try:
+            if self.keep_original:
+                shutil.copy(self.filepath, path)
+            else:
+                shutil.move(self.filepath, path)
+        except Exception as e:
+            self.report({'ERROR'}, "Installing keymap failed: %s" % e)
+            return {'CANCELLED'}
 
         # sneaky way to check we're actually running the code.
         bpy.utils.keyconfig_set(path)




More information about the Bf-blender-cvs mailing list