Changeset 2a1b92eb in sasview


Ignore:
Timestamp:
Jan 4, 2017 6:19:24 AM (7 years ago)
Author:
wojciech
Children:
c85679b
Parents:
25594ca
Message:

Writting to configuration file at the end of session

Location:
src/sas/sasgui
Files:
3 edited

Legend:

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

    rb39debba r2a1b92eb  
    21092109        Quit the application 
    21102110        """ 
     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() 
    21112114        logging.info(" --- SasView session was closed --- \n") 
    21122115        wx.Exit() 
    21132116        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 
    21142141 
    21152142    def _check_update(self, event=None): 
  • src/sas/sasgui/guiframe/startup_configuration.py

    r62243ae r2a1b92eb  
    4646                       'CLEANUP_PLOT':CURRENT.CLEANUP_PLOT, 
    4747                       'DEFAULT_PERSPECTIVE':CURRENT.DEFAULT_PERSPECTIVE, 
    48                        'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER, 
     48                       'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDE, 
    4949                       'SAS_OPENCL': None} 
    5050except: 
  • src/sas/sasgui/perspectives/fitting/gpu_options.py

    r25594ca r2a1b92eb  
    1818class CustomMessageBox(wx.Dialog): 
    1919    def __init__(self, parent, msg, title): 
     20 
    2021        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)) 
    2229        text.SetValue(msg) 
    2330        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() 
    2454        self.ShowModal() 
    2555        self.Destroy() 
     
    5080        #Check if SAS_OPENCL is already set as enviromental variable 
    5181        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) 
    5483 
    5584        for clopt in clinfo: 
     
    148177        return clinfo 
    149178 
    150  
     179    #TODO: Dont want to mess with writting to configuration file before end of 
    151180    def _write_to_config_file(self): 
    152181        from sas.sasgui.guiframe.customdir import SetupCustom 
     
    183212    def on_check(self, event): 
    184213        """ 
    185         Action triggered when button is selected 
     214        Action triggered when box is selected 
    186215        :param event: 
    187216        :return: 
     
    207236            if "SAS_OPENCL" in os.environ: 
    208237                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 
    218239        #Need to reload sasmodels.core module to account SAS_OPENCL = "None" 
    219240        reload(sasmodels.core) 
     
    224245        Close window on accpetance 
    225246        """ 
    226         import sasmodels 
    227247        for btn in self.buttons: 
    228248            btn.SetValue(0) 
    229249 
    230250        self.sas_opencl=None 
    231         del(os.environ["SAS_OPENCL"]) 
    232  
    233         try: 
    234             imp.find_module('sasmodels.kernelcl') 
    235             kernelcl_exist = True 
    236         except: 
    237             kernelcl_exist = False 
    238         if kernelcl_exist: 
    239             sasmodels.kernelcl.ENV = None 
    240  
    241         self._write_to_config_file() 
    242         reload(sasmodels.core) 
    243         event.Skip() 
    244251 
    245252    def on_test(self, event): 
     
    279286 
    280287        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: " 
    288290        if len(failures) > 0: 
    289291            msg += 'Failing tests:\n' 
    290292            msg += json.dumps(info['failing tests']) 
    291293        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" 
    293303 
    294304        CustomMessageBox(self.panel1, msg, msg_info) 
Note: See TracChangeset for help on using the changeset viewer.