Changeset 25594ca in sasview for src/sas/sasgui/perspectives/fitting
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r6c6aa83 r25594ca 14 14 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 15 15 import imp 16 17 18 class CustomMessageBox(wx.Dialog): 19 def __init__(self, parent, msg, title): 20 wx.Dialog.__init__(self, parent, title=title) 21 text = wx.TextCtrl(self, style=wx.TE_READONLY|wx.BORDER_NONE) 22 text.SetValue(msg) 23 text.SetBackgroundColour(self.GetBackgroundColour()) 24 self.ShowModal() 25 self.Destroy() 26 16 27 17 28 class GpuOptions(wx.Dialog): … … 137 148 return clinfo 138 149 139 def write_to_config_file(self): 150 151 def _write_to_config_file(self): 140 152 from sas.sasgui.guiframe.customdir import SetupCustom 141 from sas.sasgui.guiframe.gui_manager import get_app_dir, _find_local_config 142 143 PATH_APP = get_app_dir() 144 c_conf_dir = SetupCustom().setup_dir(PATH_APP) 153 from sas.sasgui.guiframe.gui_manager import _find_local_config 154 155 c_conf_dir = SetupCustom().find_dir() 145 156 self.custom_config = _find_local_config('custom_config', c_conf_dir) 146 157 if self.custom_config is None: 147 158 self.custom_config = _find_local_config('custom_config', os.getcwd()) 148 if self.custom_config is None:149 msgConfig = "Custom_config file was not imported"150 logging.info(msgConfig)151 else:152 logging.info("using custom_config in %s" % os.getcwd())153 else:154 logging.info("using custom_config from %s" % c_conf_dir)155 159 156 160 #How to store it in file 157 self.custom_config.SAS_OPENCL = self.sas_opencl 161 new_config_lines = [] 162 config_file = open(self.custom_config.__file__[:-1]) 163 if self.custom_config is not None: 164 config_lines = config_file.readlines() 165 for line in config_lines: 166 if "SAS_OPENCL" in line: 167 if self.sas_opencl: 168 new_config_lines.append("SAS_OPENCL = \""+self.sas_opencl+"\"") 169 else: 170 new_config_lines.append("SAS_OPENCL = None") 171 else: 172 new_config_lines.append(line) 173 config_file.close() 174 new_config_file = open(self.custom_config.__file__[:-1],"w") 175 new_config_file.writelines(new_config_lines) 176 new_config_file.close() 177 178 #After file is touched module needs to be reloaded 179 self.custom_config = _find_local_config('custom_config', c_conf_dir) 180 if self.custom_config is None: 181 self.custom_config = _find_local_config('custom_config', os.getcwd()) 158 182 159 183 def on_check(self, event): … … 183 207 if "SAS_OPENCL" in os.environ: 184 208 del(os.environ["SAS_OPENCL"]) 185 186 209 try: 187 210 imp.find_module('sasmodels.kernelcl') … … 191 214 if kernelcl_exist: 192 215 sasmodels.kernelcl.ENV = None 193 #self.custom_config.SAS_OPENCL = self.sas_opencl 194 216 217 self._write_to_config_file() 195 218 #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 196 219 reload(sasmodels.core) … … 201 224 Close window on accpetance 202 225 """ 226 import sasmodels 203 227 for btn in self.buttons: 204 228 btn.SetValue(0) 229 205 230 self.sas_opencl=None 231 del(os.environ["SAS_OPENCL"]) 232 233 try: 234 imp.find_module('sasmodels.kernelcl') 235 kernelcl_exist = True 236 except: 237 kernelcl_exist = False 238 if kernelcl_exist: 239 sasmodels.kernelcl.ENV = None 240 241 self._write_to_config_file() 242 reload(sasmodels.core) 243 event.Skip() 206 244 207 245 def on_test(self, event): … … 211 249 import json 212 250 import platform 213 214 251 import sasmodels 215 252 from sasmodels.model_test import model_tests 253 216 254 try: 217 255 from sasmodels.kernelcl import environment … … 239 277 'failing tests': failures, 240 278 } 241 print(json.dumps(info['failing tests'])) 279 280 msg_info = "OpenCL tests" 281 msg = "OpenCL test completed!\n" 282 msg += "Sasmodels version: " 283 msg += info['version']+"\n" 284 msg += "Platform used: " 285 msg += json.dumps(info['platform'])+"\n" 286 msg += "OpenCL driver: " 287 msg += json.dumps(info['opencl'])+"\n" 288 if len(failures) > 0: 289 msg += 'Failing tests:\n' 290 msg += json.dumps(info['failing tests']) 291 else: 292 msg+="All tests passed\n" 293 294 CustomMessageBox(self.panel1, msg, msg_info) 242 295 243 296 def on_help(self, event):
Note: See TracChangeset
for help on using the changeset viewer.