- Timestamp:
- Apr 16, 2017 1:01:30 PM (7 years ago)
- 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:
- f94a935
- Parents:
- de99a5f0 (diff), e5cbbce (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
run.py
r168d359 r6c497b7 1 # -*- coding: utf-8 -*- 1 2 #!/usr/bin/env python 3 2 4 """ 3 5 Run sasview in place. This allows sasview to use the python … … 14 16 """ 15 17 18 import imp 16 19 import os 17 20 import sys 18 import imp19 import logging20 import logging.config21 22 21 from contextlib import contextmanager 23 from os.path import abspath, dirname, join as joinpath 22 from os.path import join as joinpath 23 from os.path import abspath, dirname 24 24 25 25 26 LOGGER_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sasview/logging.ini')27 logging.config.fileConfig(LOGGER_CONFIG_FILE, disable_existing_loggers=True)28 logger = logging.getLogger(__name__)29 30 def update_all_logs_to_debug(logger):31 '''32 This updates all loggers and respective handlers to DEBUG33 '''34 for handler in logger.handlers or logger.parent.handlers:35 handler.setLevel(logging.DEBUG)36 for name,_ in logging.Logger.manager.loggerDict.items():37 logging.getLogger(name).setLevel(logging.DEBUG)38 39 26 def addpath(path): 40 27 """ … … 50 37 sys.path.insert(0, path) 51 38 39 52 40 @contextmanager 53 41 def cd(path): … … 60 48 os.chdir(old_dir) 61 49 50 62 51 def import_package(modname, path): 63 52 """Import a package into a particular point in the python namespace""" 64 53 logger.debug("Dynamicly importing: %s", path) 65 mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py')))54 mod = imp.load_source(modname, abspath(joinpath(path, '__init__.py'))) 66 55 sys.modules[modname] = mod 67 56 mod.__path__ = [abspath(path)] 68 57 return mod 58 69 59 70 60 def import_dll(modname, build_path): … … 73 63 ext = sysconfig.get_config_var('SO') 74 64 # build_path comes from context 75 path = joinpath(build_path, *modname.split('.')) +ext76 # print "importing", modname, "from", path65 path = joinpath(build_path, *modname.split('.')) + ext 66 # print "importing", modname, "from", path 77 67 return imp.load_dynamic(modname, path) 68 78 69 79 70 def prepare(): … … 87 78 from distutils.util import get_platform 88 79 root = abspath(dirname(__file__)) 89 platform = '%s-%s' %(get_platform(),sys.version[:3])90 build_path = joinpath(root, 'build', 'lib.'+platform)80 platform = '%s-%s' % (get_platform(), sys.version[:3]) 81 build_path = joinpath(root, 'build', 'lib.' + platform) 91 82 92 83 # Notify the help menu that the Sphinx documentation is in a different … … 99 90 #if not os.path.exists(mplconfig): os.mkdir(mplconfig) 100 91 #import matplotlib 101 # matplotlib.use('Agg')102 # print matplotlib.__file__92 # matplotlib.use('Agg') 93 # print matplotlib.__file__ 103 94 #import pylab; pylab.hold(False) 104 95 # add periodictable to the path 105 try: import periodictable 106 except: addpath(joinpath(root, '..','periodictable')) 96 try: 97 import periodictable 98 except: 99 addpath(joinpath(root, '..', 'periodictable')) 107 100 108 try: import bumps 109 except: addpath(joinpath(root, '..','bumps')) 101 try: 102 import bumps 103 except: 104 addpath(joinpath(root, '..', 'bumps')) 110 105 111 106 # select wx version … … 127 122 # be better to just store the package in src/sas/sasview. 128 123 import sas 129 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview'))124 sas.sasview = import_package('sas.sasview', joinpath(root, 'sasview')) 130 125 131 126 # The sas.models package Compiled Model files should be pulled in from the build directory even though … … 136 131 import sas.sascalc.pr 137 132 sas.sascalc.pr.core = import_package('sas.sascalc.pr.core', 138 joinpath(build_path, 'sas', 'sascalc', 'pr', 'core'))133 joinpath(build_path, 'sas', 'sascalc', 'pr', 'core')) 139 134 140 135 # Compiled modules need to be pulled from the build directory. … … 142 137 import sas.sascalc.file_converter 143 138 sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core', 144 joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))139 joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core')) 145 140 146 141 # Compiled modules need to be pulled from the build directory. … … 148 143 import sas.sascalc.calculator 149 144 sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core', 150 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core'))145 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core')) 151 146 152 147 sys.path.append(build_path) 153 148 154 #print "\n".join(sys.path) 149 # print "\n".join(sys.path) 150 155 151 156 152 if __name__ == "__main__": 157 update_all_logs_to_debug(logger) 153 # Need to add absolute path before actual prepare call, 154 # so logging can be done during initialization process too 155 root = abspath(dirname(__file__)) 156 addpath(joinpath(root, 'sasview')) 157 from logger_config import SetupLogger 158 logger = SetupLogger(__name__).config_development() 159 160 logger.debug("Starting SASVIEW in debug mode.") 158 161 prepare() 159 162 from sas.sasview.sasview import run 160 163 run() 161 164 logger.debug("Ending SASVIEW in debug mode.")
Note: See TracChangeset
for help on using the changeset viewer.