Changeset 2a1b92eb in sasview
- Timestamp:
- Jan 4, 2017 8:19:24 AM (8 years ago)
- Children:
- c85679b
- Parents:
- 25594ca
- Location:
- src/sas/sasgui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/gui_manager.py
rb39debba r2a1b92eb 2109 2109 Quit the application 2110 2110 """ 2111 #IF SAS_OPENCL is set, settings are stored in the custom config file 2112 if "SAS_OPENCL" in os.environ: 2113 self._write_opencl_config_file() 2111 2114 logging.info(" --- SasView session was closed --- \n") 2112 2115 wx.Exit() 2113 2116 sys.exit() 2117 2118 def _write_opencl_config_file(self): 2119 #from sas.sasgui.guiframe.customdir import SetupCustom 2120 #from sas.sasgui.guiframe.gui_manager import _find_local_config 2121 2122 sas_opencl = os.environ.get("SAS_OPENCL","") 2123 #How to store it in file 2124 new_config_lines = [] 2125 config_file = open(custom_config.__file__) 2126 if custom_config is not None: 2127 config_lines = config_file.readlines() 2128 for line in config_lines: 2129 if "SAS_OPENCL" in line: 2130 if sas_opencl: 2131 new_config_lines.append("SAS_OPENCL = \""+sas_opencl+"\"") 2132 else: 2133 new_config_lines.append("SAS_OPENCL = None") 2134 else: 2135 new_config_lines.append(line) 2136 config_file.close() 2137 new_config_file = open(custom_config.__file__,"w") 2138 new_config_file.writelines(new_config_lines) 2139 new_config_file.close() 2140 2114 2141 2115 2142 def _check_update(self, event=None): -
src/sas/sasgui/guiframe/startup_configuration.py
r62243ae r2a1b92eb 46 46 'CLEANUP_PLOT':CURRENT.CLEANUP_PLOT, 47 47 'DEFAULT_PERSPECTIVE':CURRENT.DEFAULT_PERSPECTIVE, 48 'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDE R,48 'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDE, 49 49 'SAS_OPENCL': None} 50 50 except: -
src/sas/sasgui/perspectives/fitting/gpu_options.py
r25594ca r2a1b92eb 18 18 class CustomMessageBox(wx.Dialog): 19 19 def __init__(self, parent, msg, title): 20 20 21 wx.Dialog.__init__(self, parent, title=title) 21 text = wx.TextCtrl(self, style=wx.TE_READONLY|wx.BORDER_NONE) 22 23 panel = wx.Panel(self, -1) 24 static_box = wx.StaticBox(panel, -1, "OpenCL test completed!") 25 boxsizer = wx.BoxSizer(orient=wx.VERTICAL) 26 27 text = wx.TextCtrl(self, style=wx.TE_READONLY|wx.TE_MULTILINE 28 |wx.BORDER_NONE, size=(400,200)) 22 29 text.SetValue(msg) 23 30 text.SetBackgroundColour(self.GetBackgroundColour()) 31 32 boxsizer.Add(text, 0) 33 34 fit_hsizer = wx.StaticBoxSizer(static_box, orient=wx.VERTICAL) 35 fit_hsizer.Add(boxsizer, 0, wx.ALL, 5) 36 37 panel.SetSizer(fit_hsizer) 38 39 vbox = wx.BoxSizer(wx.VERTICAL) 40 vbox.Add(panel, 0, wx.ALL, 10) 41 42 ok_btn = wx.Button(self, wx.ID_OK) 43 44 btn_sizer = wx.BoxSizer(wx.HORIZONTAL) 45 btn_sizer.Add((10, 20), 1) # stretchable whitespace 46 btn_sizer.Add(ok_btn, 0) 47 48 vbox.Add(btn_sizer, 0, wx.EXPAND|wx.ALL, 10) 49 50 self.SetSizer(vbox) 51 vbox.Fit(self) 52 53 self.Centre() 24 54 self.ShowModal() 25 55 self.Destroy() … … 50 80 #Check if SAS_OPENCL is already set as enviromental variable 51 81 self.sas_opencl = os.environ.get("SAS_OPENCL","") 52 #self.sas_opencl = os.environ["SAS_OPENCL"] \ 53 # if "SAS_OPENCL" in os.environ else SAS_OPENCL_CUSTOM 82 print("SAS_OPENCL: ",self.sas_opencl) 54 83 55 84 for clopt in clinfo: … … 148 177 return clinfo 149 178 150 179 #TODO: Dont want to mess with writting to configuration file before end of 151 180 def _write_to_config_file(self): 152 181 from sas.sasgui.guiframe.customdir import SetupCustom … … 183 212 def on_check(self, event): 184 213 """ 185 Action triggered when b uttonis selected214 Action triggered when box is selected 186 215 :param event: 187 216 :return: … … 207 236 if "SAS_OPENCL" in os.environ: 208 237 del(os.environ["SAS_OPENCL"]) 209 try: 210 imp.find_module('sasmodels.kernelcl') 211 kernelcl_exist = True 212 except: 213 kernelcl_exist = False 214 if kernelcl_exist: 215 sasmodels.kernelcl.ENV = None 216 217 self._write_to_config_file() 238 sasmodels.kernelcl.ENV = None 218 239 #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 219 240 reload(sasmodels.core) … … 224 245 Close window on accpetance 225 246 """ 226 import sasmodels227 247 for btn in self.buttons: 228 248 btn.SetValue(0) 229 249 230 250 self.sas_opencl=None 231 del(os.environ["SAS_OPENCL"])232 233 try:234 imp.find_module('sasmodels.kernelcl')235 kernelcl_exist = True236 except:237 kernelcl_exist = False238 if kernelcl_exist:239 sasmodels.kernelcl.ENV = None240 241 self._write_to_config_file()242 reload(sasmodels.core)243 event.Skip()244 251 245 252 def on_test(self, event): … … 279 286 280 287 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 289 msg = "Results: " 288 290 if len(failures) > 0: 289 291 msg += 'Failing tests:\n' 290 292 msg += json.dumps(info['failing tests']) 291 293 else: 292 msg+="All tests passed\n" 294 msg+="All tests passed!\n" 295 296 msg +="\nDetails:\n" 297 msg += "Sasmodels version: " 298 msg += info['version']+"\n" 299 msg += "\nPlatform used: " 300 msg += json.dumps(info['platform'])+"\n" 301 msg += "\nOpenCL driver: " 302 msg += json.dumps(info['opencl'])+"\n" 293 303 294 304 CustomMessageBox(self.panel1, msg, msg_info)
Note: See TracChangeset
for help on using the changeset viewer.