Changeset 914ba0a in sasview for src/sas/sasgui/perspectives/fitting/models.py
- Timestamp:
- May 2, 2017 3:58:01 PM (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/models.py
refe730d r914ba0a 2 2 Utilities to manage models 3 3 """ 4 from __future__ import print_function 5 4 6 import traceback 5 7 import os … … 20 22 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 21 23 24 logger = logging.getLogger(__name__) 25 22 26 23 27 PLUGIN_DIR = 'plugin_models' 24 28 PLUGIN_LOG = os.path.join(get_user_dir(), PLUGIN_DIR, "plugins.log") 29 PLUGIN_NAME_BASE = '[plug-in] ' 25 30 26 31 def get_model_python_path(): … … 138 143 type, value, tb = sys.exc_info() 139 144 if type is not None and issubclass(type, py_compile.PyCompileError): 140 print "Problem with", repr(value)145 print("Problem with", repr(value)) 141 146 raise type, value, tb 142 147 return 1 … … 167 172 if not os.path.isdir(dir): 168 173 msg = "SasView couldn't locate Model plugin folder %r." % dir 169 logg ing.warning(msg)174 logger.warning(msg) 170 175 return {} 171 176 172 177 plugin_log("looking for models in: %s" % str(dir)) 173 178 #compile_file(dir) #always recompile the folder plugin 174 logg ing.info("plugin model dir: %s" % str(dir))179 logger.info("plugin model dir: %s" % str(dir)) 175 180 176 181 plugins = {} … … 181 186 try: 182 187 model = load_custom_model(path) 188 model.name = PLUGIN_NAME_BASE + model.name 189 plugins[model.name] = model 183 190 except Exception: 184 191 msg = traceback.format_exc() 185 192 msg += "\nwhile accessing model in %r" % path 186 193 plugin_log(msg) 187 logg ing.warning("Failed to load plugin %r. See %s for details"194 logger.warning("Failed to load plugin %r. See %s for details" 188 195 % (path, PLUGIN_LOG)) 189 plugins[model.name] = model190 196 191 197 return plugins … … 259 265 if self.is_changed(): 260 266 return _findModels(dir) 261 logg ing.info("plugin model : %s" % str(temp))267 logger.info("plugin model : %s" % str(temp)) 262 268 return temp 263 269 … … 291 297 for name, plug in self.stored_plugins.iteritems(): 292 298 self.model_dictionary[name] = plug 293 299 294 300 self._get_multifunc_models() 295 301 … … 323 329 self.plugins.append(plug) 324 330 self.model_dictionary[name] = plug 325 self.model_combobox.set_list(" CustomizedModels", self.plugins)331 self.model_combobox.set_list("Plugin Models", self.plugins) 326 332 return self.model_combobox.get_list() 327 333 else: … … 344 350 self.model_dictionary[name] = plug 345 351 346 self.model_combobox.reset_list(" CustomizedModels", self.plugins)352 self.model_combobox.reset_list("Plugin Models", self.plugins) 347 353 return self.model_combobox.get_list() 348 354 … … 355 361 """ 356 362 if int(evt.GetId()) in self.form_factor_dict.keys(): 357 from sas .sascalc.fit.MultiplicationModel import MultiplicationModel363 from sasmodels.sasview_model import MultiplicationModel 358 364 self.model_dictionary[MultiplicationModel.__name__] = MultiplicationModel 359 365 model1, model2 = self.form_factor_dict[int(evt.GetId())] … … 387 393 # self.shape_indep_list) 388 394 self.model_combobox.set_list("Structure Factors", self.struct_list) 389 self.model_combobox.set_list(" CustomizedModels", self.plugins)395 self.model_combobox.set_list("Plugin Models", self.plugins) 390 396 self.model_combobox.set_list("P(Q)*S(Q)", self.multiplication_factor) 391 397 self.model_combobox.set_list("multiplication", … … 412 418 """ 413 419 __modelmanager = ModelManagerBase() 414 cat_model_list = [ model_namefor model_name \420 cat_model_list = [__modelmanager.model_dictionary[model_name] for model_name \ 415 421 in __modelmanager.model_dictionary.keys() \ 416 422 if model_name not in __modelmanager.stored_plugins.keys()]
Note: See TracChangeset
for help on using the changeset viewer.