Changeset c6bdb3b in sasview for src/sas/sasgui/__init__.py


Ignore:
Timestamp:
May 2, 2017 10:03:50 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:
a67ec83
Parents:
7c105e8
Message:

more fiddling with configs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/__init__.py

    r914ba0a rc6bdb3b  
    4747 
    4848def get_app_dir(): 
    49     if APP_FOLDER is None: 
    50         raise RuntimeError("Need to initialize sas.sasgui.USER_FOLDER") 
    5149    return APP_FOLDER 
    5250 
    5351def get_user_dir(): 
    54     if USER_FOLDER is None: 
    55         raise RuntimeError("Need to initialize sas.sasgui.USER_FOLDER") 
    5652    return USER_FOLDER 
    5753 
     
    7470    import os 
    7571    import sys 
    76     import imp 
    7772    import logging 
     73    from sasmodels.custom import load_module_from_path 
    7874 
    7975    logger = logging.getLogger(__name__) 
     
    8177    filename = 'local_config.py' 
    8278    path = os.path.join(dirname, filename) 
    83     if os.path.exists(path): 
    84         try: 
    85             fObj = None 
    86             fObj, config_path, descr = imp.find_module('local_config', [APP_FOLDER]) 
    87             config = imp.load_module('local_config', fObj, config_path, descr) 
    88             logger.info("GuiManager loaded %s" % config_path) 
    89             return config 
    90         except Exception: 
    91             import traceback; logger.error(traceback.format_exc()) 
    92             logger.error("Error loading %s: %s" % (path, sys.exc_value)) 
    93         finally: 
    94             if fObj is not None: 
    95                 fObj.close() 
    96     from sas.sasgui.guiframe import config 
    97     logger.info("GuiManager config defaults to sas.sasgui.guiframe") 
    98     return config 
    99  
     79    try: 
     80        module = load_module_from_path('sas.sasgui.local_config', path) 
     81        logger.info("GuiManager loaded %s", path) 
     82        return module 
     83    except Exception as exc: 
     84        logger.critical("Error loading %s: %s", path, exc) 
     85        sys.exit() 
Note: See TracChangeset for help on using the changeset viewer.