Changeset 62243ae in sasview


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

Added settings reading from custom config file

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sasview/custom_config.py

    r79492222 r62243ae  
    1515TOOLBAR_SHOW = True 
    1616DEFAULT_PERSPECTIVE = "Fitting" 
     17SAS_OPENCL = None 
  • sasview/local_config.py

    r49e000b r62243ae  
    140140UPDATE_TIMEOUT = 2 
    141141 
     142#OpenCL option 
     143SAS_OPENCL = None 
     144 
    142145def printEVT(message): 
    143146    if __EVT_DEBUG__: 
  • src/sas/sasgui/guiframe/gui_manager.py

    r67b0a99 r62243ae  
    152152SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    153153SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
     154SAS_OPENCL = config.SAS_OPENCL 
    154155if not WELCOME_PANEL_ON: 
    155156    WELCOME_PANEL_SHOW = False 
     
    176177    else: 
    177178        DEFAULT_OPEN_FOLDER = PATH_APP 
     179    SAS_OPENCL = custom_config.SAS_OPENCL 
    178180except: 
    179181    DATALOADER_SHOW = True 
     
    190192    CLEANUP_PLOT = False 
    191193    DEFAULT_OPEN_FOLDER = PATH_APP 
    192  
     194    SAS_OPENCL = None 
    193195DEFAULT_STYLE = config.DEFAULT_STYLE 
    194196 
     
    225227        CHILD_FRAME = wx.Frame 
    226228 
     229#Initiliaze enviromental variable with custom setting but only if variable not set 
     230if SAS_OPENCL and not "SAS_OPENCL" in os.environ: 
     231    os.environ["SAS_OPENCL"] = SAS_OPENCL 
    227232 
    228233class ViewerFrame(PARENT_FRAME): 
  • src/sas/sasgui/guiframe/startup_configuration.py

    rd85c194 r62243ae  
    3131                   'CLEANUP_PLOT':False, 
    3232                   'DEFAULT_PERSPECTIVE':'Fitting', 
    33                    'DEFAULT_OPEN_FOLDER': None} 
     33                   'DEFAULT_OPEN_FOLDER': None, 
     34                   'SAS_OPENCL': None} 
    3435try: 
    3536    CURRENT_STRINGS = {'GUIFRAME_WIDTH':CURRENT.GUIFRAME_WIDTH, 
     
    4546                       'CLEANUP_PLOT':CURRENT.CLEANUP_PLOT, 
    4647                       'DEFAULT_PERSPECTIVE':CURRENT.DEFAULT_PERSPECTIVE, 
    47                        'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER} 
     48                       'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER, 
     49                       'SAS_OPENCL': None} 
    4850except: 
    4951    CURRENT_STRINGS = DEFAULT_STRINGS 
  • 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.