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>2011-08-08 13:09:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-08 13:09:44 +0400
commit64a298645f91e2ae4a64891fec68e76a712f145c (patch)
tree084665dff602179cbda07f16405ffc52e72b96f8
parent24acf58fc47f1ed6132bcaa07b86b756e1b3194a (diff)
report error on installign keymaps rather then raising an exception.
-rw-r--r--release/scripts/startup/bl_ui/space_userpref_keymap.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py
index 9736ea5bc22..f63da6551de 100644
--- a/release/scripts/startup/bl_ui/space_userpref_keymap.py
+++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py
@@ -542,24 +542,24 @@ class WM_OT_keyconfig_import(bpy.types.Operator):
def execute(self, context):
from os.path import basename
import shutil
- if not self.filepath:
- raise Exception("Filepath not set")
- # simply check we can open
- f = open(self.filepath, "r")
- if not f:
- raise Exception("Could not open file")
- f.close()
+ if not self.filepath:
+ self.report({'ERROR'}, "Filepath not set")
+ return {'CANCELLED'}
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)