Changeset 2f733b1 in sasmodels


Ignore:
Timestamp:
Mar 6, 2018 9:56:22 AM (7 years ago)
Author:
krzywon
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
f9c8474
Parents:
a22d104
Message:

Make exception handling more specific when attempting to load models.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    ra22d104 r2f733b1  
    898898    load it from :mod:`sasmodels.models`. 
    899899    """ 
    900     # TODO: Keep current scheme (.py looks in custom folders) 
    901     plugin_path = environ.get('PLUGIN_MODEL_DIR', None) 
    902900    if model_name.endswith('.py'): 
    903901        kernel_module = load_custom_kernel_module(model_name) 
     
    907905            __import__('sasmodels.models.'+model_name) 
    908906            kernel_module = getattr(models, model_name, None) 
    909         except Exception: 
     907        except ImportError: 
     908            # If the model isn't a built in model, try the plugin directory 
     909            plugin_path = environ.get('PLUGIN_MODEL_DIR', None) 
    910910            if plugin_path is not None: 
    911911                file_name = model_name.split(sep)[-1] 
    912912                model_name = plugin_path + sep + file_name + ".py" 
    913             kernel_module = load_custom_kernel_module(model_name) 
     913                kernel_module = load_custom_kernel_module(model_name) 
     914            else: 
     915                raise 
    914916    return kernel_module 
    915917 
Note: See TracChangeset for help on using the changeset viewer.