Ignore:
Timestamp:
Jul 24, 2017 10:27:05 AM (7 years ago)
Author:
krzywon
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.
Message:

Merge branch 'master' into 4_1_issues

# Conflicts:
# docs/sphinx-docs/source/conf.py
# src/sas/sascalc/dataloader/readers/cansas_reader.py
# src/sas/sasgui/guiframe/documentation_window.py
# src/sas/sasgui/perspectives/fitting/models.py

File:
1 edited

Legend:

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

    r05b8e01 r6a455cd3  
    22    Utilities to manage models 
    33""" 
     4from __future__ import print_function 
     5 
    46import traceback 
    57import os 
     
    1921from sasmodels.sasview_model import load_custom_model, load_standard_models 
    2022from sas.sasgui.perspectives.fitting.fitpage import CUSTOM_MODEL 
     23 
     24logger = logging.getLogger(__name__) 
    2125 
    2226 
     
    140144        type, value, tb = sys.exc_info() 
    141145        if type is not None and issubclass(type, py_compile.PyCompileError): 
    142             print "Problem with", repr(value) 
     146            print("Problem with", repr(value)) 
    143147            raise type, value, tb 
    144148        return 1 
     
    153157    try: 
    154158        import compileall 
    155         compileall.compile_dir(dir=dir, ddir=dir, force=1, 
     159        compileall.compile_dir(dir=dir, ddir=dir, force=0, 
    156160                               quiet=report_problem) 
    157161    except: 
     
    160164 
    161165 
    162 def _findModels(dir): 
     166def _find_models(): 
    163167    """ 
    164168    Find custom models 
    165169    """ 
    166170    # List of plugin objects 
    167     dir = find_plugins_dir() 
     171    directory = find_plugins_dir() 
    168172    # 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         logging.warning(msg) 
     173    if not os.path.isdir(directory): 
     174        msg = "SasView couldn't locate Model plugin folder %r." % directory 
     175        logger.warning(msg) 
    172176        return {} 
    173177 
    174     plugin_log("looking for models in: %s" % str(dir)) 
    175     #compile_file(dir)  #always recompile the folder plugin 
    176     logging.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)) 
    177181 
    178182    plugins = {} 
    179     for filename in os.listdir(dir): 
     183    for filename in os.listdir(directory): 
    180184        name, ext = os.path.splitext(filename) 
    181185        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)) 
    183187            try: 
    184188                model = load_custom_model(path) 
     
    189193                msg += "\nwhile accessing model in %r" % path 
    190194                plugin_log(msg) 
    191                 logging.warning("Failed to load plugin %r. See %s for details" 
    192                                 % (path, PLUGIN_LOG)) 
    193              
     195                logger.warning("Failed to load plugin %r. See %s for details" 
     196                               % (path, PLUGIN_LOG)) 
     197 
    194198    return plugins 
    195199 
     
    261265        temp = {} 
    262266        if self.is_changed(): 
    263             temp =  _findModels(dir) 
     267            temp =  _findModels() 
    264268            self.last_time_dir_modified = time.time() 
    265269            return temp 
    266         logging.info("plugin model : %s" % str(temp)) 
     270        logger.info("plugin model : %s" % str(temp)) 
    267271        return temp 
    268272 
     
    338342        """ 
    339343        self.plugins = [] 
    340         new_plugins = _findModels(dir) 
     344        new_plugins = _find_models() 
    341345        for name, plug in  new_plugins.iteritems(): 
    342346            for stored_name, stored_plug in self.stored_plugins.iteritems(): 
Note: See TracChangeset for help on using the changeset viewer.