Changeset 6af411b in sasview for src/sas


Ignore:
Timestamp:
Dec 21, 2016 8:39:58 AM (8 years ago)
Author:
wojciech
Children:
62243ae
Parents:
bd55e15
Message:

Towards saving in comnfig file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    rbd55e15 r6af411b  
    1111import warnings 
    1212import wx 
    13  
     13import logging 
    1414from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    1515 
     
    2525    def __init__(self, *args, **kwds): 
    2626 
     27        from sas.sasgui.guiframe.customdir import SetupCustom 
     28 
     29        c_conf_dir = SetupCustom().setup_dir(PATH_APP) 
     30        self.custom_config = _find_local_config('custom_config', c_conf_dir) 
     31        if self.custom_config is None: 
     32            self.custom_config = _find_local_config('custom_config', os.getcwd()) 
     33            if self.custom_config is None: 
     34                msgConfig = "Custom_config file was not imported" 
     35                logging.info(msgConfig) 
     36            else: 
     37                logging.info("using custom_config in %s" % os.getcwd()) 
     38        else: 
     39            logging.info("using custom_config from %s" % c_conf_dir) 
     40        SAS_OPENCL_CUSTOM = custom_config.SAS_OPENCL 
     41 
    2742        kwds["style"] = wx.DEFAULT_DIALOG_STYLE 
    2843        wx.Dialog.__init__(self, *args, **kwds) 
     
    3651        self.option_button = {} 
    3752        self.buttons = [] 
    38         #Check if SAS_OPENCL is already set 
    39         self.sas_opencl = os.environ.get("SAS_OPENCL","") 
     53        #Check if SAS_OPENCL is already set as enviromental variable 
     54        self.sas_opencl =  os.environ["SAS_OPENCL"] \ 
     55            if "SAS_OPENCL" in os.environ else SAS_OPENCL_CUSTOM 
     56        #or as a custom variable in the config file 
     57 
    4058        for clopt in clinfo: 
    4159            button = wx.CheckBox(self.panel1, -1, label=clopt[1], name=clopt[1]) 
     
    156174        if self.sas_opencl: 
    157175            os.environ["SAS_OPENCL"] = self.sas_opencl 
    158         else: 
     176            else: 
    159177            if "SAS_OPENCL" in os.environ: 
    160178                del(os.environ["SAS_OPENCL"]) 
    161179        sasmodels.kernelcl.ENV = None 
     180        #TODO: Write to config.py 
     181        self.custom_config.SAS_OPENCL = self.sas_opencl 
     182 
    162183        #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 
    163184        reload(sasmodels.core) 
Note: See TracChangeset for help on using the changeset viewer.