Ignore:
Timestamp:
May 2, 2017 3:58:01 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
d66dbcc
Parents:
74d9780 (diff), 658dd57 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/models.py

    refe730d r914ba0a  
    22    Utilities to manage models 
    33""" 
     4from __future__ import print_function 
     5 
    46import traceback 
    57import os 
     
    2022from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 
    2123 
     24logger = logging.getLogger(__name__) 
     25 
    2226 
    2327PLUGIN_DIR = 'plugin_models' 
    2428PLUGIN_LOG = os.path.join(get_user_dir(), PLUGIN_DIR, "plugins.log") 
     29PLUGIN_NAME_BASE = '[plug-in] ' 
    2530 
    2631def get_model_python_path(): 
     
    138143        type, value, tb = sys.exc_info() 
    139144        if type is not None and issubclass(type, py_compile.PyCompileError): 
    140             print "Problem with", repr(value) 
     145            print("Problem with", repr(value)) 
    141146            raise type, value, tb 
    142147        return 1 
     
    167172    if not os.path.isdir(dir): 
    168173        msg = "SasView couldn't locate Model plugin folder %r." % dir 
    169         logging.warning(msg) 
     174        logger.warning(msg) 
    170175        return {} 
    171176 
    172177    plugin_log("looking for models in: %s" % str(dir)) 
    173178    #compile_file(dir)  #always recompile the folder plugin 
    174     logging.info("plugin model dir: %s" % str(dir)) 
     179    logger.info("plugin model dir: %s" % str(dir)) 
    175180 
    176181    plugins = {} 
     
    181186            try: 
    182187                model = load_custom_model(path) 
     188                model.name = PLUGIN_NAME_BASE + model.name 
     189                plugins[model.name] = model 
    183190            except Exception: 
    184191                msg = traceback.format_exc() 
    185192                msg += "\nwhile accessing model in %r" % path 
    186193                plugin_log(msg) 
    187                 logging.warning("Failed to load plugin %r. See %s for details" 
     194                logger.warning("Failed to load plugin %r. See %s for details" 
    188195                                % (path, PLUGIN_LOG)) 
    189             plugins[model.name] = model 
    190196 
    191197    return plugins 
     
    259265        if self.is_changed(): 
    260266            return  _findModels(dir) 
    261         logging.info("plugin model : %s" % str(temp)) 
     267        logger.info("plugin model : %s" % str(temp)) 
    262268        return temp 
    263269 
     
    291297        for name, plug in self.stored_plugins.iteritems(): 
    292298            self.model_dictionary[name] = plug 
    293          
     299 
    294300        self._get_multifunc_models() 
    295301 
     
    323329                    self.plugins.append(plug) 
    324330                    self.model_dictionary[name] = plug 
    325             self.model_combobox.set_list("Customized Models", self.plugins) 
     331            self.model_combobox.set_list("Plugin Models", self.plugins) 
    326332            return self.model_combobox.get_list() 
    327333        else: 
     
    344350            self.model_dictionary[name] = plug 
    345351 
    346         self.model_combobox.reset_list("Customized Models", self.plugins) 
     352        self.model_combobox.reset_list("Plugin Models", self.plugins) 
    347353        return self.model_combobox.get_list() 
    348354 
     
    355361        """ 
    356362        if int(evt.GetId()) in self.form_factor_dict.keys(): 
    357             from sas.sascalc.fit.MultiplicationModel import MultiplicationModel 
     363            from sasmodels.sasview_model import MultiplicationModel 
    358364            self.model_dictionary[MultiplicationModel.__name__] = MultiplicationModel 
    359365            model1, model2 = self.form_factor_dict[int(evt.GetId())] 
     
    387393#                                     self.shape_indep_list) 
    388394        self.model_combobox.set_list("Structure Factors", self.struct_list) 
    389         self.model_combobox.set_list("Customized Models", self.plugins) 
     395        self.model_combobox.set_list("Plugin Models", self.plugins) 
    390396        self.model_combobox.set_list("P(Q)*S(Q)", self.multiplication_factor) 
    391397        self.model_combobox.set_list("multiplication", 
     
    412418    """ 
    413419    __modelmanager = ModelManagerBase() 
    414     cat_model_list = [model_name for model_name \ 
     420    cat_model_list = [__modelmanager.model_dictionary[model_name] for model_name \ 
    415421                      in __modelmanager.model_dictionary.keys() \ 
    416422                      if model_name not in __modelmanager.stored_plugins.keys()] 
Note: See TracChangeset for help on using the changeset viewer.