Changes in / [b796c72:aaa801e] in sasview
- Files:
-
- 1 added
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified installers/setup_exe.py ¶
rb963b20 r92df9cbd 46 46 sys.path.insert(0, build_path) 47 47 48 from sas.sasview import local_config 48 49 from installer_generator import generate_installer 49 50 … … 73 74 sys.exc_value) 74 75 75 from sas import get_local_config76 local_config = get_local_config()77 76 78 77 # Solution taken from here: http://www.py2exe.org/index.cgi/win32com.shell -
TabularUnified installers/setup_mac.py ¶
rb963b20 r67d8b1b 45 45 import macholib_patch 46 46 47 from sas import get_local_config 48 local_config = get_local_config() 47 from sas.sasview import local_config 49 48 50 49 ICON = local_config.SetupIconFile_mac -
TabularUnified src/sas/__init__.py ¶
rb963b20 r79492222 1 __all__ = ['get_app_dir', 'get_user_dir',2 'get_local_config', 'get_custom_config']3 4 _APP_DIR = None5 def get_app_dir():6 """7 The directory where the sasview application is found.8 9 Returns the path to sasview if running in place or installed with setup.10 If the application is frozen, returns the parent directory of the11 application resources such as test files and images.12 """13 global _APP_DIR14 if not _APP_DIR:15 from ._config import find_app_dir16 _APP_DIR = find_app_dir()17 return _APP_DIR18 19 _USER_DIR = None20 def get_user_dir():21 """22 The directory where the per-user configuration is stored.23 24 Returns ~/.sasview, creating it if it does not already exist.25 """26 global _USER_DIR27 if not _USER_DIR:28 from ._config import make_user_dir29 _USER_DIR = make_user_dir()30 return _USER_DIR31 32 def make_custom_config_path():33 from ._config import make_custom_config_path as _make_path34 return _make_path(get_user_dir())35 36 _CUSTOM_CONFIG = None37 def get_custom_config():38 """39 Setup the custom config dir and cat file40 """41 global _CUSTOM_CONFIG42 if not _CUSTOM_CONFIG:43 from ._config import setup_custom_config44 _CUSTOM_CONFIG = setup_custom_config(get_app_dir(), get_user_dir())45 return _CUSTOM_CONFIG46 47 48 _LOCAL_CONFIG = None49 def get_local_config():50 """51 Loads the local config file.52 """53 global _LOCAL_CONFIG54 if not _LOCAL_CONFIG:55 from ._config import load_local_config56 _LOCAL_CONFIG = load_local_config(get_app_dir())57 return _LOCAL_CONFIG -
TabularUnified src/sas/sascalc/fit/models.py ¶
rb963b20 r9706d88 15 15 from sasmodels.sasview_model import load_custom_model, load_standard_models 16 16 17 from sas import get_user_dir17 from sas.sasgui import get_user_dir 18 18 19 19 # Explicitly import from the pluginmodel module so that py2exe -
TabularUnified src/sas/sasgui/__init__.py ¶
rb963b20 rc6bdb3b 1 import sys 2 import os 3 from os.path import exists, expanduser, dirname, realpath, join as joinpath 4 5 6 def dirn(path, n): 7 path = realpath(path) 8 for _ in range(n): 9 path = dirname(path) 10 return path 11 12 # Set up config directories 13 def make_user_folder(): 14 path = joinpath(expanduser("~"),'.sasview') 15 if not exists(path): 16 os.mkdir(path) 17 return path 18 19 20 def find_app_folder(): 21 # We are starting out with the following info: 22 # __file__ = .../sas/sasgui/__init__.pyc 23 # Check if the sister path .../sas/sasview exists, and use it as the 24 # app directory. This will only be the case if the app is not frozen. 25 path = joinpath(dirn(__file__, 2), 'sasview') 26 if exists(path): 27 return path 28 29 # If we are running frozen, then root is a parent directory 30 if sys.platform == 'darwin': 31 # Here is the path to the file on the mac: 32 # .../Sasview.app/Contents/Resources/lib/python2.7/site-packages.zip/sas/sasgui/__init__.pyc 33 # We want the path to the Resources directory. 34 path = dirn(__file__, 6) 35 elif os.name == 'nt': 36 # Here is the path to the file on windows: 37 # ../Sasview/library.zip/sas/sasgui/__init__.pyc 38 # We want the path to the Sasview directory. 39 path = dirn(__file__, 4) 40 else: 41 raise RuntimeError("Couldn't find the app directory") 42 return path 43 44 USER_FOLDER = make_user_folder() 45 APP_FOLDER = find_app_folder() 46 47 48 def get_app_dir(): 49 return APP_FOLDER 50 51 def get_user_dir(): 52 return USER_FOLDER 53 54 def get_custom_config_path(): 55 dirname = os.path.join(get_user_dir(), 'config') 56 # If the directory doesn't exist, create it 57 if not os.path.exists(dirname): 58 os.makedirs(dirname) 59 path = os.path.join(dirname, "custom_config.py") 60 return path 61 62 _config_cache = None 63 def get_local_config(): 64 global _config_cache 65 if not _config_cache: 66 _config_cache = _load_config() 67 return _config_cache 68 69 def _load_config(): 70 import os 71 import sys 72 import logging 73 from sasmodels.custom import load_module_from_path 74 75 logger = logging.getLogger(__name__) 76 dirname = get_app_dir() 77 filename = 'local_config.py' 78 path = os.path.join(dirname, filename) 79 try: 80 module = load_module_from_path('sas.sasgui.local_config', path) 81 logger.info("GuiManager loaded %s", path) 82 return module 83 except Exception as exc: 84 logger.critical("Error loading %s: %s", path, exc) 85 sys.exit() -
TabularUnified src/sas/sasgui/guiframe/CategoryInstaller.py ¶
rb963b20 r6e50a8d 15 15 from collections import defaultdict, OrderedDict 16 16 17 from sas import get_user_dir17 from sas.sasgui import get_user_dir 18 18 19 19 USER_FILE = 'categories.json' -
TabularUnified src/sas/sasgui/guiframe/aboutbox.py ¶
rb963b20 r959eb01 25 25 import os 26 26 27 from sas import get_local_config27 from sas.sasgui import get_local_config 28 28 config = get_local_config() 29 29 -
TabularUnified src/sas/sasgui/guiframe/acknowledgebox.py ¶
rb963b20 r74c8cd0 13 13 from wx.lib.expando import ExpandoTextCtrl 14 14 15 from sas import get_local_config15 from sas.sasgui import get_local_config 16 16 config = get_local_config() 17 17 -
TabularUnified src/sas/sasgui/guiframe/config.py ¶
rb963b20 rd908932 145 145 UPDATE_TIMEOUT = 2 146 146 147 #OpenCL option 148 SAS_OPENCL = None 149 147 150 # Time out for updating sasview 148 151 UPDATE_TIMEOUT = 2 -
TabularUnified src/sas/sasgui/guiframe/data_panel.py ¶
rb963b20 rc6bdb3b 33 33 from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot \ 34 34 import PlotFrame as QucikPlotDialog 35 from sas import get_local_config35 from sas.sasgui import get_local_config 36 36 37 37 config = get_local_config() -
TabularUnified src/sas/sasgui/guiframe/documentation_window.py ¶
rb963b20 r2746eab 27 27 WX_SUPPORTS_HTML2 = False 28 28 29 from sas import get_app_dir29 from sas.sasgui import get_app_dir 30 30 31 31 # Don't use wx html renderer on windows. -
TabularUnified src/sas/sasgui/guiframe/gui_manager.py ¶
rb963b20 r2f22db9 28 28 from matplotlib import _pylab_helpers 29 29 30 from sas import get_local_config, get_custom_config, get_app_dir, get_user_dir30 from sas.sasgui import get_local_config, get_app_dir, get_user_dir 31 31 from sas.sasgui.guiframe.events import EVT_CATEGORY 32 32 from sas.sasgui.guiframe.events import EVT_STATUS … … 47 47 from sas.sascalc.dataloader.loader import Loader 48 48 from sas.sasgui.guiframe.proxy import Connection 49 from sas.sasgui.guiframe.customdir import setup_custom_config 49 50 50 51 logger = logging.getLogger(__name__) … … 52 53 53 54 config = get_local_config() 54 custom_config = get_custom_config()55 custom_config = setup_custom_config() 55 56 56 57 # read some constants from config … … 62 63 SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 63 64 SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 65 SAS_OPENCL = config.SAS_OPENCL 64 66 if not WELCOME_PANEL_ON: 65 67 WELCOME_PANEL_SHOW = False … … 136 138 PARENT_FRAME = wx.Frame 137 139 CHILD_FRAME = wx.Frame 140 141 #Initiliaze enviromental variable with custom setting but only if variable not set 142 if SAS_OPENCL and not "SAS_OPENCL" in os.environ: 143 os.environ["SAS_OPENCL"] = SAS_OPENCL 138 144 139 145 class ViewerFrame(PARENT_FRAME): -
TabularUnified src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py ¶
rb963b20 rdcb91cf 10 10 logger = logging.getLogger(__name__) 11 11 12 from sas import get_local_config13 14 12 from sas.sascalc.dataloader.loader import Loader 15 13 from sas.sascalc.dataloader.loader_exceptions import NoKnownLoaderException 16 14 15 from sas.sasgui import get_local_config 17 16 from sas.sasgui.guiframe.plugin_base import PluginBase 18 17 from sas.sasgui.guiframe.events import StatusEvent -
TabularUnified src/sas/sasgui/guiframe/startup_configuration.py ¶
rb963b20 r7432acb 13 13 import wx 14 14 15 from sas import make_custom_config_path15 from sas.sasgui import get_custom_config_path 16 16 from sas.sasgui.guiframe.events import StatusEvent 17 17 from sas.sasgui.guiframe.gui_style import GUIFRAME … … 194 194 Write custom configuration 195 195 """ 196 path = make_custom_config_path()196 path = get_custom_config_path() 197 197 with open(path, 'w') as out_f: 198 198 out_f.write("#Application appearance custom configuration\n") -
TabularUnified src/sas/sasview/local_config.py ¶
rb963b20 rc6bdb3b 145 145 UPDATE_TIMEOUT = 2 146 146 147 #OpenCL option 148 SAS_OPENCL = None 149 147 150 # Time out for updating sasview 148 151 UPDATE_TIMEOUT = 2 -
TabularUnified src/sas/sasview/sasview.py ¶
rb963b20 r1693141 20 20 reload(sys) 21 21 sys.setdefaultencoding("iso-8859-1") 22 23 import sas24 22 25 23 APP_NAME = 'SasView' … … 173 171 174 172 175 def setup_mpl(backend=None): 173 def setup_mpl(backend='WXAgg'): 174 import sas.sasgui 176 175 # Always use private .matplotlib setup to avoid conflicts with other 177 mplconfigdir = os.path.join(sas. get_user_dir(), '.matplotlib')176 mplconfigdir = os.path.join(sas.sasgui.get_user_dir(), '.matplotlib') 178 177 if not os.path.exists(mplconfigdir): 179 178 os.mkdir(mplconfigdir) … … 193 192 Prepare sasmodels for running within sasview. 194 193 """ 194 import sas.sasgui 195 195 # Set SAS_MODELPATH so sasmodels can find our custom models 196 plugin_dir = os.path.join(sas. get_user_dir(), PLUGIN_MODEL_DIR)196 plugin_dir = os.path.join(sas.sasgui.get_user_dir(), PLUGIN_MODEL_DIR) 197 197 os.environ['SAS_MODELPATH'] = plugin_dir 198 #Initiliaze enviromental variable with custom setting but only if variable not set 199 SAS_OPENCL = sas.get_custom_config().SAS_OPENCL 200 if SAS_OPENCL and "SAS_OPENCL" not in os.environ: 201 os.environ["SAS_OPENCL"] = SAS_OPENCL 198 # TODO: SAS_OPENCL flag belongs in setup_sasmodels 199 # this will require restructuring of the config management so that it 200 # can occur outside of sasgui. 202 201 203 202 def run_gui(): … … 208 207 freeze_support() 209 208 setup_logging() 210 setup_mpl( backend='WXAgg')209 setup_mpl() 211 210 setup_sasmodels() 212 211 setup_wx() … … 218 217 freeze_support() 219 218 setup_logging() 220 # Use default matplotlib backend on mac/linux, but wx on windows. 221 # The problem on mac is that the wx backend requires pythonw. On windows 222 # we are sure to wx since it is the shipped with the app. 223 setup_mpl(backend='WXAgg' if os.name == 'nt' else None) 219 setup_mpl(backend='Agg') 224 220 setup_sasmodels() 225 221 if len(sys.argv) == 1 or sys.argv[1] == '-i': -
TabularUnified src/sas/sasview/welcome_panel.py ¶
rb963b20 rd66dbcc 10 10 from wx.lib.scrolledpanel import ScrolledPanel 11 11 12 from sas import get_local_config12 from sas.sasgui import get_local_config 13 13 from sas.sasgui.guiframe.panel_base import PanelBase 14 14 config = get_local_config()
Note: See TracChangeset
for help on using the changeset viewer.