Changeset 6a455cd3 in sasview for src/sas/sasgui/perspectives/fitting/models.py
- Timestamp:
- Jul 24, 2017 10:27:05 AM (7 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:
- 146c669
- Parents:
- b61bd57 (diff), bc04647 (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
r05b8e01 r6a455cd3 2 2 Utilities to manage models 3 3 """ 4 from __future__ import print_function 5 4 6 import traceback 5 7 import os … … 19 21 from sasmodels.sasview_model import load_custom_model, load_standard_models 20 22 from sas.sasgui.perspectives.fitting.fitpage import CUSTOM_MODEL 23 24 logger = logging.getLogger(__name__) 21 25 22 26 … … 140 144 type, value, tb = sys.exc_info() 141 145 if type is not None and issubclass(type, py_compile.PyCompileError): 142 print "Problem with", repr(value)146 print("Problem with", repr(value)) 143 147 raise type, value, tb 144 148 return 1 … … 153 157 try: 154 158 import compileall 155 compileall.compile_dir(dir=dir, ddir=dir, force= 1,159 compileall.compile_dir(dir=dir, ddir=dir, force=0, 156 160 quiet=report_problem) 157 161 except: … … 160 164 161 165 162 def _find Models(dir):166 def _find_models(): 163 167 """ 164 168 Find custom models 165 169 """ 166 170 # List of plugin objects 167 dir = find_plugins_dir()171 directory = find_plugins_dir() 168 172 # Go through files in plug-in directory 169 if not os.path.isdir(dir ):170 msg = "SasView couldn't locate Model plugin folder %r." % dir 171 logg ing.warning(msg)173 if not os.path.isdir(directory): 174 msg = "SasView couldn't locate Model plugin folder %r." % directory 175 logger.warning(msg) 172 176 return {} 173 177 174 plugin_log("looking for models in: %s" % str(dir ))175 # compile_file(dir) #always recompile the folder plugin176 logg ing.info("plugin model dir: %s" % str(dir))178 plugin_log("looking for models in: %s" % str(directory)) 179 # compile_file(directory) #always recompile the folder plugin 180 logger.info("plugin model dir: %s" % str(directory)) 177 181 178 182 plugins = {} 179 for filename in os.listdir(dir ):183 for filename in os.listdir(directory): 180 184 name, ext = os.path.splitext(filename) 181 185 if ext == '.py' and not name == '__init__': 182 path = os.path.abspath(os.path.join(dir , filename))186 path = os.path.abspath(os.path.join(directory, filename)) 183 187 try: 184 188 model = load_custom_model(path) … … 189 193 msg += "\nwhile accessing model in %r" % path 190 194 plugin_log(msg) 191 logg ing.warning("Failed to load plugin %r. See %s for details"192 193 195 logger.warning("Failed to load plugin %r. See %s for details" 196 % (path, PLUGIN_LOG)) 197 194 198 return plugins 195 199 … … 261 265 temp = {} 262 266 if self.is_changed(): 263 temp = _findModels( dir)267 temp = _findModels() 264 268 self.last_time_dir_modified = time.time() 265 269 return temp 266 logg ing.info("plugin model : %s" % str(temp))270 logger.info("plugin model : %s" % str(temp)) 267 271 return temp 268 272 … … 338 342 """ 339 343 self.plugins = [] 340 new_plugins = _find Models(dir)344 new_plugins = _find_models() 341 345 for name, plug in new_plugins.iteritems(): 342 346 for stored_name, stored_plug in self.stored_plugins.iteritems():
Note: See TracChangeset
for help on using the changeset viewer.