Changeset d81008e in sasview for sansguiframe
- Timestamp:
- Aug 10, 2011 9:15:56 AM (13 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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 51db68f
- Parents:
- ff06528
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/gui_manager.py
rc642155 rd81008e 16 16 import sys 17 17 import xml 18 19 18 import py_compile 20 19 # Try to find a local config 21 20 import imp 22 DATAPATH = os.getcwd()23 tem_path = sys.path[0]24 if os.path.isfile(tem_path):25 tem_path = os.path.dirname(tem_path)26 os.chdir(tem_path)27 PATH_APP = os.getcwd()28 if(os.path.isfile("%s/%s.py" % (PATH_APP, 'local_config'))) or \29 (os.path.isfile("%s/%s.pyc" % (PATH_APP, 'local_config'))):30 fObj, path_config, descr = imp.find_module('local_config', [PATH_APP])31 try:32 config = imp.load_module('local_config', fObj, path_config, descr)33 except:34 # Didn't find local config, load the default35 import config36 finally:37 if fObj:38 fObj.close()39 else:40 # Try simply importing local_config41 import local_config as config42 43 #import compileall44 import py_compile45 46 c_name = os.path.join(PATH_APP, 'custom_config.py')47 if(os.path.isfile("%s/%s.py" % (PATH_APP, 'custom_config'))):48 py_compile.compile(file=c_name)49 #compileall.compile_dir(dir=path, force=True, quiet=0)50 cfObj, path_cconfig, descr = imp.find_module('custom_config', [PATH_APP])51 try:52 custom_config = imp.load_module('custom_config', cfObj, PATH_APP, descr)53 except:54 custom_config = None55 finally:56 if custom_config != None:57 cfObj.close()58 59 60 21 import warnings 61 22 warnings.simplefilter("ignore") 62 63 23 import logging 64 24 … … 79 39 from sans.dataloader.loader import Loader 80 40 41 DATAPATH = os.getcwd() 42 tem_path = sys.path[0] 43 if os.path.isfile(tem_path): 44 tem_path = os.path.dirname(tem_path) 45 os.chdir(tem_path) 46 PATH_APP = os.getcwd() 47 48 def _find_local_config(file, path): 49 """ 50 Find configuration file for the current application 51 """ 52 53 file_path = os.path.abspath(os.path.join(path, "%s.py" % file)) 54 if(os.path.isfile(file_path)): 55 py_compile.compile(file=file_path) 56 fObj, path_config, descr = imp.find_module(file, [path]) 57 try: 58 return imp.load_module(file, fObj, path_config, descr) 59 except: 60 raise 61 finally: 62 if fObj: 63 fObj.close() 64 65 66 try: 67 path = PATH_APP 68 config = _find_local_config('local_config', path) 69 if config is None: 70 path, _ = os.path.split(PATH_APP) 71 config = _find_local_config('local_config', path) 72 except: 73 # Didn't find local config, load the default 74 import sans.guiframe.config as config 75 try: 76 path = PATH_APP 77 custom_config = _find_local_config('custom_config', path) 78 if custom_config is None: 79 path, _ = os.path.split(PATH_APP) 80 custom_config = _find_local_config('custom_config', path) 81 except: 82 msg = "Custom_config file was not imported" 83 logging.info(msg) 84 81 85 82 86 #read some constants from config
Note: See TracChangeset
for help on using the changeset viewer.