Changeset c6bdb3b in sasview


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

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r7c105e8 rc6bdb3b  
    11# -*- coding: utf-8 -*- 
    22#!/usr/bin/env python 
    3  
    43""" 
    54Run sasview in place.  This allows sasview to use the python 
     
    1514the given module or script. 
    1615""" 
     16from __future__ import print_function 
    1717 
    1818import imp 
  • 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() 
  • src/sas/sasgui/guiframe/config.py

    r914ba0a rc6bdb3b  
    11""" 
    2     Application settings 
     2Application settings 
    33""" 
    44from __future__ import print_function 
     
    66import time 
    77import os 
     8import logging 
     9 
    810from sas.sasgui.guiframe.gui_style import GUIFRAME 
    911import sas.sasview 
    10 import logging 
    11  
    1212 
    1313logger = logging.getLogger(__name__) 
     
    7575_ansto_logo = os.path.join(icon_path, "ansto_logo.png") 
    7676_tudelft_logo = os.path.join(icon_path, "tudelft_logo.png") 
     77_dls_logo = os.path.join(icon_path, "dls_logo.png") 
    7778_nsf_logo = os.path.join(icon_path, "nsf_logo.png") 
    7879_danse_logo = os.path.join(icon_path, "danse_logo.png") 
  • src/sas/sasgui/guiframe/customdir.py

    r914ba0a rc6bdb3b  
    11# Setup and find Custom config dir 
     2from __future__ import print_function 
     3 
    24import os.path 
    35import logging 
    46import shutil 
    5 import imp 
    67 
    7 from sas.sasgui import get_custom_config_path 
     8from sasmodels.custom import load_module_from_path 
     9 
     10from sas.sasgui import get_custom_config_path, get_app_dir 
    811 
    912logger = logging.getLogger(__name__) 
     
    2225def _setup_custom_config(): 
    2326    path = get_custom_config_path() 
    24     try: 
    25         if not os.path.isfile(path): 
     27    if not os.path.isfile(path): 
     28        try: 
    2629            # if the custom config file does not exist, copy the default from 
    2730            # the app dir 
    2831            shutil.copyfile(os.path.join(get_app_dir(), "custom_config.py"), 
    2932                            path) 
    30         #Adding SAS_OPENCL if it doesn't exist in the config file 
    31         # - to support backcompability 
    32         if not "SAS_OPENCL" in open(path).read(): 
     33        except Exception: 
     34            logger.error("Could not copy default custom config.") 
     35 
     36    #Adding SAS_OPENCL if it doesn't exist in the config file 
     37    # - to support backcompability 
     38    if not "SAS_OPENCL" in open(path).read(): 
     39        try: 
    3340            open(config_file, "a+").write("SAS_OPENCL = \"None\"\n") 
    34     except Exception: 
    35         #import traceback; logging.error(traceback.format_exc()) 
    36         logger.error("Could not copy default custom config.") 
     41        except Exception: 
     42            logger.error("Could not update custom config with SAS_OPENCL.") 
    3743 
    3844    custom_config = _load_config(path) 
    3945    return custom_config 
    4046 
     47 
    4148def _load_config(path): 
    4249    if os.path.exists(path): 
    4350        try: 
    44             fObj = None 
    45             fObj, config_path, descr = imp.find_module('custom_config', [os.path.dirname(path)]) 
    46             custom_config = imp.load_module('custom_config', fObj, config_path, descr) 
    47             logger.info("GuiManager loaded %s" % config_path) 
    48             return custom_config 
    49         except Exception: 
    50             logger.error("Error loading %s: %s" % (path, sys.exc_value)) 
    51         finally: 
    52             if fObj is not None: 
    53                 fObj.close() 
     51            module = load_module_from_path('sas.sasview.custom_config', path) 
     52            logger.info("GuiManager loaded %s", path) 
     53            return module 
     54        except Exception as exc: 
     55            logger.error("Error loading %s: %s", path, exc) 
     56 
    5457    from sas.sasview import custom_config 
    55     logging.info("GuiManager custom_config defaults to sas.sasview.custom_config") 
     58    logger.info("GuiManager custom_config defaults to sas.sasview.custom_config") 
    5659    return custom_config 
  • src/sas/sasgui/guiframe/data_panel.py

    ra1b8fee rc6bdb3b  
    3333from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot \ 
    3434    import PlotFrame as QucikPlotDialog 
    35 import sas.sasgui.guiframe.config as config 
     35from sas.sasgui import get_local_config 
     36 
     37config = get_local_config() 
    3638 
    3739# Check version 
  • src/sas/sasview/local_config.py

    r914ba0a rc6bdb3b  
    9494_corner_image = os.path.join(icon_path, "angles_flat.png") 
    9595_welcome_image = os.path.join(icon_path, "SVwelcome.png") 
    96 _copyright = "(c) 2009 - 2017, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft and DLS" 
     96_copyright = "(c) 2009 - 2017, UTK, UMD, NIST, ORNL, ISIS, ESS, ILL, ANSTO, TU Delft, and DLS" 
    9797marketplace_url = "http://marketplace.sasview.org/" 
    9898 
     
    148148SAS_OPENCL = None 
    149149 
     150# Time out for updating sasview 
     151UPDATE_TIMEOUT = 2 
     152 
    150153def printEVT(message): 
    151154    if __EVT_DEBUG__: 
Note: See TracChangeset for help on using the changeset viewer.