Changeset f36e01f in sasview for run.py


Ignore:
Timestamp:
Apr 11, 2017 4:08:57 AM (7 years ago)
Author:
Ricardo Ferraz Leal <ricleal@…>
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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b854587
Parents:
09983d1
Message:

Some pylint enhancements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • run.py

    r7fb59b2 rf36e01f  
    11# -*- coding: utf-8 -*- 
    22#!/usr/bin/env python 
     3 
    34""" 
    45Run sasview in place.  This allows sasview to use the python 
     
    1617 
    1718import imp 
    18 import logging 
    19 import logging.config 
    2019import os 
    2120import sys 
     
    3837    sys.path.insert(0, path) 
    3938 
     39 
    4040@contextmanager 
    4141def cd(path): 
     
    4848    os.chdir(old_dir) 
    4949 
     50 
    5051def import_package(modname, path): 
    5152    """Import a package into a particular point in the python namespace""" 
    52     mod = imp.load_source(modname, abspath(joinpath(path,'__init__.py'))) 
     53    mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py'))) 
    5354    sys.modules[modname] = mod 
    5455    mod.__path__ = [abspath(path)] 
    5556    return mod 
     57 
    5658 
    5759def import_dll(modname, build_path): 
     
    6062    ext = sysconfig.get_config_var('SO') 
    6163    # build_path comes from context 
    62     path = joinpath(build_path, *modname.split('.'))+ext 
    63     #print "importing", modname, "from", path 
     64    path = joinpath(build_path, *modname.split('.')) + ext 
     65    # print "importing", modname, "from", path 
    6466    return imp.load_dynamic(modname, path) 
     67 
    6568 
    6669def prepare(): 
     
    7477    from distutils.util import get_platform 
    7578    root = abspath(dirname(__file__)) 
    76     platform = '%s-%s'%(get_platform(),sys.version[:3]) 
    77     build_path = joinpath(root, 'build','lib.'+platform) 
     79    platform = '%s-%s' % (get_platform(), sys.version[:3]) 
     80    build_path = joinpath(root, 'build', 'lib.' + platform) 
    7881 
    7982    # Notify the help menu that the Sphinx documentation is in a different 
     
    8689    #if not os.path.exists(mplconfig): os.mkdir(mplconfig) 
    8790    #import matplotlib 
    88     #matplotlib.use('Agg') 
    89     #print matplotlib.__file__ 
     91    # matplotlib.use('Agg') 
     92    # print matplotlib.__file__ 
    9093    #import pylab; pylab.hold(False) 
    9194    # add periodictable to the path 
    92     try: import periodictable 
    93     except: addpath(joinpath(root, '..','periodictable')) 
     95    try: 
     96        import periodictable 
     97    except: 
     98        addpath(joinpath(root, '..', 'periodictable')) 
    9499 
    95     try: import bumps 
    96     except: addpath(joinpath(root, '..','bumps')) 
     100    try: 
     101        import bumps 
     102    except: 
     103        addpath(joinpath(root, '..', 'bumps')) 
    97104 
    98105    # select wx version 
     
    114121    # be better to just store the package in src/sas/sasview. 
    115122    import sas 
    116     sas.sasview = import_package('sas.sasview', joinpath(root,'sasview')) 
     123    sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview')) 
    117124 
    118125    # The sas.models package Compiled Model files should be pulled in from the build directory even though 
     
    123130    import sas.sascalc.pr 
    124131    sas.sascalc.pr.core = import_package('sas.sascalc.pr.core', 
    125                                   joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 
     132                                         joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 
    126133 
    127134    # Compiled modules need to be pulled from the build directory. 
     
    129136    import sas.sascalc.file_converter 
    130137    sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core', 
    131                                   joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))                     
     138                                                     joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core')) 
    132139 
    133140    # Compiled modules need to be pulled from the build directory. 
     
    135142    import sas.sascalc.calculator 
    136143    sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core', 
    137                                   joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 
     144                                                 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 
    138145 
    139146    sys.path.append(build_path) 
    140147 
    141     #print "\n".join(sys.path) 
     148    # print "\n".join(sys.path) 
     149 
    142150 
    143151if __name__ == "__main__": 
    144     #Need to add absolute path before actual prepare call, 
    145     #so logging can be done during initialization process too 
     152    # Need to add absolute path before actual prepare call, 
     153    # so logging can be done during initialization process too 
    146154    root = abspath(dirname(__file__)) 
    147155    addpath(joinpath(root, 'sasview')) 
Note: See TracChangeset for help on using the changeset viewer.