Changeset 1693141 in sasview for src/sas


Ignore:
Timestamp:
Sep 20, 2017 7:26:56 PM (7 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:
92df9cbd
Parents:
5a405bd
Message:

fix broken startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasview/sasview.py

    r60a7820 r1693141  
    2121sys.setdefaultencoding("iso-8859-1") 
    2222 
     23APP_NAME = 'SasView' 
    2324PLUGIN_MODEL_DIR = 'plugin_models' 
    24 APP_NAME = 'SasView' 
    25  
    26 # Set SAS_MODELPATH so sasmodels can find our custom models 
    27 os.environ['SAS_MODELPATH'] = os.path.join(sasdir, PLUGIN_MODEL_DIR) 
    28  
    29 class SasView(): 
     25 
     26class SasView(object): 
    3027    """ 
    3128    Main class for running the SasView application 
     
    163160 
    164161 
    165 def setup_mpl(): 
     162def setup_mpl(backend='WXAgg'): 
    166163    import sas.sasgui 
    167164    # Always use private .matplotlib setup to avoid conflicts with other 
     
    174171    # we are running may not actually need it; also, putting as little on the 
    175172    # path as we can 
    176     os.environ['MPLBACKEND'] = 'WXAgg' 
    177  
     173    os.environ['MPLBACKEND'] = backend 
     174 
     175    # TODO: ... so much for not importing matplotlib unless we need it... 
    178176    from matplotlib import backend_bases 
    179177    backend_bases.FigureCanvasBase.filetypes.pop('pgf', None) 
    180178 
     179def setup_sasmodels(): 
     180    """ 
     181    Prepare sasmodels for running within sasview. 
     182    """ 
     183    import sas.sasgui 
     184    # Set SAS_MODELPATH so sasmodels can find our custom models 
     185    plugin_dir = os.path.join(sas.sasgui.get_user_dir(), PLUGIN_MODEL_DIR) 
     186    os.environ['SAS_MODELPATH'] = plugin_dir 
     187    # TODO: SAS_OPENCL flag belongs in setup_sasmodels 
     188    # this will require restructuring of the config management so that it 
     189    # can occur outside of sasgui. 
    181190 
    182191def run_gui(): 
     
    187196    freeze_support() 
    188197    setup_logging() 
     198    setup_mpl() 
     199    setup_sasmodels() 
    189200    setup_wx() 
    190     setup_mpl() 
    191201    SasView() 
    192202 
    193203 
    194204def run_cli(): 
     205    from multiprocessing import freeze_support 
     206    freeze_support() 
    195207    setup_logging() 
    196     setup_mpl() 
     208    setup_mpl(backend='Agg') 
     209    setup_sasmodels() 
    197210    if len(sys.argv) == 1: 
    198211        # Run sasview as an interactive python interpreter 
Note: See TracChangeset for help on using the changeset viewer.