diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-03 20:23:05 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-03 20:23:05 +0300 |
commit | 010e955654483c4e5de63d399bd15c5ec4def2d2 (patch) | |
tree | 1838e5834287d844e56dfb00322e5ea44623a0aa /rigify/metarig_menu.py | |
parent | 17de4c60631c5c9e68032a6aacd6003f92513765 (diff) |
Rigify: improve robustness with bad feature set packages.
Verify the basic expected directory structure inside the ZIP
archive before installing it, and catch exceptions when loading
the already installed packages.
Diffstat (limited to 'rigify/metarig_menu.py')
-rw-r--r-- | rigify/metarig_menu.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/rigify/metarig_menu.py b/rigify/metarig_menu.py index 18d8e550..2c8adac7 100644 --- a/rigify/metarig_menu.py +++ b/rigify/metarig_menu.py @@ -19,6 +19,8 @@ # <pep8 compliant> import os +import traceback + from string import capwords import bpy @@ -44,7 +46,11 @@ def get_metarigs(base_path, path, depth=0): metarigs = {} - files = os.listdir(os.path.join(base_path, path)) + try: + files = os.listdir(os.path.join(base_path, path)) + except FileNotFoundError: + files = [] + files.sort() for f in files: @@ -216,9 +222,19 @@ def get_external_metarigs(feature_sets_path): for feature_set in os.listdir(feature_sets_path): if feature_set: - utils.get_resource(os.path.join(feature_set, '__init__'), base_path=feature_sets_path) - - metarigs['external'].update(get_metarigs(feature_sets_path, os.path.join(feature_set, utils.METARIG_DIR))) + try: + try: + utils.get_resource(os.path.join(feature_set, '__init__'), feature_sets_path) + except FileNotFoundError: + print("Rigify Error: Could not load feature set '%s': __init__.py not found.\n" % (feature_set)) + continue + + metarigs['external'].update(get_metarigs(feature_sets_path, os.path.join(feature_set, utils.METARIG_DIR))) + except Exception: + print("Rigify Error: Could not load feature set '%s' metarigs: exception occurred.\n" % (feature_set)) + traceback.print_exc() + print("") + continue metarig_ops.clear() armature_submenus.clear() |