Changeset 914ba0a in sasview for run.py


Ignore:
Timestamp:
May 2, 2017 3:58:01 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:
d66dbcc
Parents:
74d9780 (diff), 658dd57 (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 with master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r899e084 r914ba0a  
     1# -*- coding: utf-8 -*- 
    12#!/usr/bin/env python 
     3 
    24""" 
    35Run sasview in place.  This allows sasview to use the python 
     
    1416""" 
    1517 
     18import imp 
    1619import os 
    1720import sys 
    18 import imp 
    1921from contextlib import contextmanager 
    20 from os.path import abspath, dirname, join as joinpath 
     22from os.path import join as joinpath 
     23from os.path import abspath, dirname 
    2124 
    2225 
     
    3437    sys.path.insert(0, path) 
    3538 
     39 
    3640@contextmanager 
    3741def cd(path): 
     
    4448    os.chdir(old_dir) 
    4549 
     50 
    4651def import_package(modname, path): 
    4752    """Import a package into a particular point in the python namespace""" 
    48     mod = imp.load_source(modname, abspath(joinpath(path,'__init__.py'))) 
     53    mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py'))) 
    4954    sys.modules[modname] = mod 
    5055    mod.__path__ = [abspath(path)] 
    5156    return mod 
     57 
    5258 
    5359def import_dll(modname, build_path): 
     
    5662    ext = sysconfig.get_config_var('SO') 
    5763    # build_path comes from context 
    58     path = joinpath(build_path, *modname.split('.'))+ext 
    59     #print "importing", modname, "from", path 
     64    path = joinpath(build_path, *modname.split('.')) + ext 
     65    # print "importing", modname, "from", path 
    6066    return imp.load_dynamic(modname, path) 
     67 
    6168 
    6269def prepare(): 
     
    7077    from distutils.util import get_platform 
    7178    root = abspath(dirname(__file__)) 
    72     platform = '%s-%s'%(get_platform(),sys.version[:3]) 
    73     build_path = joinpath(root, 'build','lib.'+platform) 
    74      
    75     # Notify the help menu that the Sphinx documentation is in a different  
     79    platform = '%s-%s' % (get_platform(), sys.version[:3]) 
     80    build_path = joinpath(root, 'build', 'lib.' + platform) 
     81 
     82    # Notify the help menu that the Sphinx documentation is in a different 
    7683    # place than it otherwise would be. 
    7784    os.environ['SASVIEW_DOC_PATH'] = joinpath(build_path, "doc") 
     
    8289    #if not os.path.exists(mplconfig): os.mkdir(mplconfig) 
    8390    #import matplotlib 
    84     #matplotlib.use('Agg') 
    85     #print matplotlib.__file__ 
     91    # matplotlib.use('Agg') 
     92    # print matplotlib.__file__ 
    8693    #import pylab; pylab.hold(False) 
    8794    # add periodictable to the path 
    88     try: import periodictable 
    89     except: addpath(joinpath(root, '..','periodictable')) 
     95    try: 
     96        import periodictable 
     97    except: 
     98        addpath(joinpath(root, '..', 'periodictable')) 
    9099 
    91     try: import bumps 
    92     except: addpath(joinpath(root, '..','bumps')) 
     100    try: 
     101        import bumps 
     102    except: 
     103        addpath(joinpath(root, '..', 'bumps')) 
    93104 
    94105    # select wx version 
     
    114125    import sas.sascalc.pr 
    115126    sas.sascalc.pr.core = import_package('sas.sascalc.pr.core', 
    116                                   joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 
     127                                         joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 
     128 
     129    # Compiled modules need to be pulled from the build directory. 
     130    # Some packages are not where they are needed, so load them explicitly. 
     131    import sas.sascalc.file_converter 
     132    sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core', 
     133                                                     joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core')) 
    117134 
    118135    import sas.sascalc.calculator 
    119136    sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core', 
    120                                   joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 
     137                                                 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 
    121138 
    122139    sys.path.append(build_path) 
    123140 
    124     #print "\n".join(sys.path) 
     141    # print "\n".join(sys.path) 
     142 
    125143 
    126144if __name__ == "__main__": 
     145    # Need to add absolute path before actual prepare call, 
     146    # so logging can be done during initialization process too 
     147    root = abspath(dirname(__file__)) 
     148    addpath(joinpath(root, 'sasview')) 
     149    from logger_config import SetupLogger 
     150    logger = SetupLogger(__name__).config_development() 
     151 
     152    logger.debug("Starting SASVIEW in debug mode.") 
    127153    prepare() 
    128154    from sas.sasview.sasview import run_gui 
    129155    run_gui() 
     156    logger.debug("Ending SASVIEW in debug mode.") 
Note: See TracChangeset for help on using the changeset viewer.