Changeset e2c0939 in sasview


Ignore:
Timestamp:
Jan 5, 2017 9:43:08 AM (8 years ago)
Author:
wojciech
Children:
92583049
Parents:
c85679b
Message:

Setting proper CL env even when initiated from None

Location:
src/sas/sasgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/gui_manager.py

    r2a1b92eb re2c0939  
    21102110        """ 
    21112111        #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() 
     2112        self._write_opencl_config_file() 
    21142113        logging.info(" --- SasView session was closed --- \n") 
    21152114        wx.Exit() 
     
    21202119        #from sas.sasgui.guiframe.gui_manager import _find_local_config 
    21212120 
    2122         sas_opencl = os.environ.get("SAS_OPENCL","") 
     2121        sas_opencl = os.environ.get("SAS_OPENCL",None) 
    21232122        #How to store it in file 
    21242123        new_config_lines = [] 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r2a1b92eb re2c0939  
    1111import warnings 
    1212import wx 
    13 import logging 
    1413from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    15 import imp 
     14 
    1615 
    1716 
     
    8079        #Check if SAS_OPENCL is already set as enviromental variable 
    8180        self.sas_opencl = os.environ.get("SAS_OPENCL","") 
    82         print("SAS_OPENCL: ",self.sas_opencl) 
    83  
     81         
    8482        for clopt in clinfo: 
    8583            button = wx.CheckBox(self.panel1, -1, label=clopt[1], name=clopt[1]) 
     
    177175        return clinfo 
    178176 
    179     #TODO: Dont want to mess with writting to configuration file before end of 
    180     def _write_to_config_file(self): 
    181         from sas.sasgui.guiframe.customdir import SetupCustom 
    182         from sas.sasgui.guiframe.gui_manager import _find_local_config 
    183  
    184         c_conf_dir = SetupCustom().find_dir() 
    185         self.custom_config = _find_local_config('custom_config', c_conf_dir) 
    186         if self.custom_config is None: 
    187             self.custom_config = _find_local_config('custom_config', os.getcwd()) 
    188  
    189         #How to store it in file 
    190         new_config_lines = [] 
    191         config_file = open(self.custom_config.__file__[:-1]) 
    192         if self.custom_config is not None: 
    193             config_lines = config_file.readlines() 
    194             for line in config_lines: 
    195                 if "SAS_OPENCL" in line: 
    196                     if self.sas_opencl: 
    197                         new_config_lines.append("SAS_OPENCL = \""+self.sas_opencl+"\"") 
    198                     else: 
    199                         new_config_lines.append("SAS_OPENCL = None") 
    200                 else: 
    201                     new_config_lines.append(line) 
    202         config_file.close() 
    203         new_config_file = open(self.custom_config.__file__[:-1],"w") 
    204         new_config_file.writelines(new_config_lines) 
    205         new_config_file.close() 
    206  
    207         #After file is touched module needs to be reloaded 
    208         self.custom_config = _find_local_config('custom_config', c_conf_dir) 
    209         if self.custom_config is None: 
    210             self.custom_config = _find_local_config('custom_config', os.getcwd()) 
    211  
    212177    def on_check(self, event): 
    213178        """ 
     
    236201            if "SAS_OPENCL" in os.environ: 
    237202                del(os.environ["SAS_OPENCL"]) 
    238         sasmodels.kernelcl.ENV = None 
     203 
     204        #Sasmodels kernelcl doesn't exist when initiated with None 
     205        try: 
     206            sasmodels.kernelcl.ENV = None 
     207        except: 
     208            pass 
     209 
    239210        #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 
    240211        reload(sasmodels.core) 
Note: See TracChangeset for help on using the changeset viewer.