- Timestamp:
- Jun 27, 2016 7:36:41 AM (8 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 80c2c85
- Parents:
- efe730d
- Location:
- src/sas/sasview
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasview/__init__.py
refe730d r899e084 1 __version__ = "4.0.0 -a3"1 __version__ = "4.0.0a4" 2 2 __build__ = "1" -
src/sas/sasview/sasview.py
refe730d r899e084 16 16 import traceback 17 17 18 log_file = os.path.join(os.path.expanduser("~"), 'sasview.log') 19 logging.basicConfig(level=logging.INFO, 20 format='%(asctime)s %(levelname)s %(message)s', 21 filename=log_file, 22 ) 23 logging.captureWarnings(True) 18 19 reload(sys) 20 sys.setdefaultencoding("iso-8859-1") 21 24 22 25 23 class StreamToLogger(object): … … 41 39 self.logger.log(self.log_level, line.rstrip()) 42 40 43 stderr_logger = logging.getLogger('STDERR')44 sl = StreamToLogger(stderr_logger, logging.ERROR)45 sys.stderr = sl46 47 # Log the start of the session48 logging.info(" --- SasView session started ---")49 50 # Log the python version51 logging.info("Python: %s" % sys.version)52 53 # Allow the dynamic selection of wxPython via an environment variable, when devs54 # who have multiple versions of the module installed want to pick between them.55 # This variable does not have to be set of course, and through normal usage will56 # probably not be, but this can make things a little easier when upgrading to a57 # new version of wx.58 WX_ENV_VAR = "SASVIEW_WX_VERSION"59 if WX_ENV_VAR in os.environ:60 logging.info("You have set the %s environment variable to %s." % \61 (WX_ENV_VAR, os.environ[WX_ENV_VAR]))62 import wxversion63 if wxversion.checkInstalled(os.environ[WX_ENV_VAR]):64 logging.info("Version %s of wxPython is installed, so using that version." % os.environ[WX_ENV_VAR])65 wxversion.select(os.environ[WX_ENV_VAR])66 else:67 logging.error("Version %s of wxPython is not installed, so using default version." % os.environ[WX_ENV_VAR])68 else:69 logging.info("You have not set the %s environment variable, so using default version of wxPython." % WX_ENV_VAR)70 71 import wx72 73 try:74 logging.info("Wx version: %s" % wx.__version__)75 except:76 logging.error("Wx version: error reading version")77 78 from . import wxcruft79 wxcruft.call_later_fix()80 #wxcruft.trace_new_id()81 #Always use private .matplotlib setup to avoid conflicts with other82 #uses of matplotlib83 84 import sas.sasgui85 mplconfigdir = os.path.join(sas.sasgui.get_user_dir(), '.matplotlib')86 if not os.path.exists(mplconfigdir):87 os.mkdir(mplconfigdir)88 os.environ['MPLCONFIGDIR'] = mplconfigdir89 reload(sys)90 sys.setdefaultencoding("iso-8859-1")91 92 93 from sas.sasgui.guiframe import gui_manager94 from .welcome_panel import WelcomePanel95 41 PLUGIN_MODEL_DIR = 'plugin_models' 96 42 APP_NAME = 'SasView' … … 103 49 """ 104 50 """ 105 #from gui_manager importViewApp106 self.gui = gui_manager.SasViewApp(0)51 from sas.sasgui.guiframe.gui_manager import SasViewApp 52 self.gui = SasViewApp(0) 107 53 # Set the application manager for the GUI 108 54 self.gui.set_manager(self) … … 116 62 # Fitting perspective 117 63 try: 118 import sas.sasgui.perspectives.fitting as module 64 import sas.sasgui.perspectives.fitting as module 119 65 fitting_plug = module.Plugin() 120 66 self.gui.add_perspective(fitting_plug) … … 142 88 logging.error(traceback.format_exc()) 143 89 144 #Calculator perspective 90 #Calculator perspective 145 91 try: 146 92 import sas.sasgui.perspectives.calculator as module … … 154 100 155 101 # Add welcome page 102 from .welcome_panel import WelcomePanel 156 103 self.gui.set_welcome_panel(WelcomePanel) 157 104 … … 164 111 165 112 166 def run(): 113 def setup_logging(): 114 log_file = os.path.join(os.path.expanduser("~"), 'sasview.log') 115 logging.basicConfig(level=logging.INFO, 116 format='%(asctime)s %(levelname)s %(message)s', 117 filename=log_file, 118 ) 119 logging.captureWarnings(True) 120 121 stderr_logger = logging.getLogger('STDERR') 122 sl = StreamToLogger(stderr_logger, logging.ERROR) 123 sys.stderr = sl 124 125 # Log the start of the session 126 logging.info(" --- SasView session started ---") 127 128 # Log the python version 129 logging.info("Python: %s" % sys.version) 130 131 132 def setup_wx(): 133 # Allow the dynamic selection of wxPython via an environment variable, when devs 134 # who have multiple versions of the module installed want to pick between them. 135 # This variable does not have to be set of course, and through normal usage will 136 # probably not be, but this can make things a little easier when upgrading to a 137 # new version of wx. 138 WX_ENV_VAR = "SASVIEW_WX_VERSION" 139 if WX_ENV_VAR in os.environ: 140 logging.info("You have set the %s environment variable to %s." % \ 141 (WX_ENV_VAR, os.environ[WX_ENV_VAR])) 142 import wxversion 143 if wxversion.checkInstalled(os.environ[WX_ENV_VAR]): 144 logging.info("Version %s of wxPython is installed, so using that version." % os.environ[WX_ENV_VAR]) 145 wxversion.select(os.environ[WX_ENV_VAR]) 146 else: 147 logging.error("Version %s of wxPython is not installed, so using default version." % os.environ[WX_ENV_VAR]) 148 else: 149 logging.info("You have not set the %s environment variable, so using default version of wxPython." % WX_ENV_VAR) 150 151 import wx 152 153 try: 154 logging.info("Wx version: %s" % wx.__version__) 155 except: 156 logging.error("Wx version: error reading version") 157 158 from . import wxcruft 159 wxcruft.call_later_fix() 160 #wxcruft.trace_new_id() 161 #Always use private .matplotlib setup to avoid conflicts with other 162 #uses of matplotlib 163 164 165 def setup_mpl(): 166 import sas.sasgui 167 mplconfigdir = os.path.join(sas.sasgui.get_user_dir(), '.matplotlib') 168 if not os.path.exists(mplconfigdir): 169 os.mkdir(mplconfigdir) 170 os.environ['MPLCONFIGDIR'] = mplconfigdir 171 # Set backend to WXAgg; this overrides matplotlibrc, but shouldn't override 172 # mpl.use(). Note: Don't import matplotlib here since the script that 173 # we are running may not actually need it; also, putting as little on the 174 # path as we can 175 os.environ['MPLBACKEND'] = 'WXAgg' 176 177 178 def run_gui(): 167 179 """ 168 180 __main__ method for loading and running SasView … … 170 182 from multiprocessing import freeze_support 171 183 freeze_support() 172 if len(sys.argv) > 1: 173 ## Run sasview as an interactive python interpreter 174 if sys.argv[1] == "-i": 175 sys.argv = ["ipython", "--pylab"] 176 from IPython import start_ipython 177 sys.exit(start_ipython()) 184 setup_logging() 185 setup_wx() 186 setup_mpl() 187 SasView() 188 189 190 def run_cli(): 191 setup_mpl() 192 if len(sys.argv) == 1: 193 # Run sasview as an interactive python interpreter 194 sys.argv = ["ipython", "--pylab"] 195 from IPython import start_ipython 196 sys.exit(start_ipython()) 197 else: 198 # Run sasview as a python script interpreter 178 199 thing_to_run = sys.argv[1] 179 200 sys.argv = sys.argv[1:] … … 183 204 else: 184 205 runpy.run_module(thing_to_run, run_name="__main__") 185 else:186 SasView()187 206 188 207 if __name__ == "__main__": 189 run ()190 208 run_gui() 209
Note: See TracChangeset
for help on using the changeset viewer.