Changeset 62243ae in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Dec 22, 2016 6:36:12 AM (8 years ago)
Author:
wojciech
Children:
6c6aa83
Parents:
6af411b
Message:

Added settings reading from custom config file

File:
1 edited

Legend:

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

    r6af411b r62243ae  
    1313import logging 
    1414from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     15import imp 
    1516 
    1617class GpuOptions(wx.Dialog): 
     
    2526    def __init__(self, *args, **kwds): 
    2627 
    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 
     28        # from sas.sasgui.guiframe.customdir import SetupCustom 
     29        # from sas.sasgui.guiframe.gui_manager import get_app_dir, _find_local_config 
     30        # 
     31        # PATH_APP = get_app_dir() 
     32        # c_conf_dir = SetupCustom().setup_dir(PATH_APP) 
     33        # self.custom_config = _find_local_config('custom_config', c_conf_dir) 
     34        # if self.custom_config is None: 
     35        #     self.custom_config = _find_local_config('custom_config', os.getcwd()) 
     36        #     if self.custom_config is None: 
     37        #         msgConfig = "Custom_config file was not imported" 
     38        #         logging.info(msgConfig) 
     39        #     else: 
     40        #         logging.info("using custom_config in %s" % os.getcwd()) 
     41        # else: 
     42        #     logging.info("using custom_config from %s" % c_conf_dir) 
     43 
     44        # SAS_OPENCL_CUSTOM = None 
     45        # if self.custom_config.SAS_OPENCL: 
     46        #     SAS_OPENCL_CUSTOM = self.custom_config.SAS_OPENCL 
    4147 
    4248        kwds["style"] = wx.DEFAULT_DIALOG_STYLE 
     
    5258        self.buttons = [] 
    5359        #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 
     60        self.sas_opencl = os.environ.get("SAS_OPENCL","") 
     61        #self.sas_opencl =  os.environ["SAS_OPENCL"] \ 
     62        #    if "SAS_OPENCL" in os.environ else SAS_OPENCL_CUSTOM 
    5763 
    5864        for clopt in clinfo: 
     
    6571            else: 
    6672                self.option_button[clopt] = "None" 
    67                 if self.sas_opencl.lower() == "none" : 
     73                if self.sas_opencl.lower() == "none": 
    6874                    button.SetValue(1) 
    6975 
     
    174180        if self.sas_opencl: 
    175181            os.environ["SAS_OPENCL"] = self.sas_opencl 
    176             else: 
     182        else: 
    177183            if "SAS_OPENCL" in os.environ: 
    178184                del(os.environ["SAS_OPENCL"]) 
    179         sasmodels.kernelcl.ENV = None 
    180         #TODO: Write to config.py 
    181         self.custom_config.SAS_OPENCL = self.sas_opencl 
     185 
     186        try: 
     187            imp.find_module('sasmodels.kernelcl') 
     188            kernelcl_exist = True 
     189        except: 
     190            kernelcl_exist = False 
     191        if kernelcl_exist: 
     192            sasmodels.kernelcl.ENV = None 
     193            #self.custom_config.SAS_OPENCL = self.sas_opencl 
    182194 
    183195        #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 
Note: See TracChangeset for help on using the changeset viewer.