Changeset 67346f9 in sasview for src


Ignore:
Timestamp:
Nov 12, 2018 5:59:11 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
9d23e4c
Parents:
859d960
git-author:
Piotr Rozyczko <piotr.rozyczko@…> (11/12/18 05:48:13)
git-committer:
Piotr Rozyczko <piotr.rozyczko@…> (11/12/18 05:59:11)
Message:

Save load path and sas_opencl values to the custom config, if changed
during the session.

Location:
src/sas/qtgui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r859d960 r67346f9  
    5252        # Read in default locations 
    5353        self.default_save_location = None 
    54         self.default_load_location = os.path.join(os.path.dirname(sys.argv[0]), "test") 
     54        self.default_load_location = GuiUtils.DEFAULT_OPEN_FOLDER 
    5555        self.default_project_location = None 
    5656 
  • src/sas/qtgui/MainWindow/GuiManager.py

    r1942f63 r67346f9  
    354354        # Exit if yes 
    355355        if reply == QMessageBox.Yes: 
     356            # save the paths etc. 
     357            self.saveCustomConfig() 
    356358            reactor.callFromThread(reactor.stop) 
    357359            return True 
     
    10711073        elif isinstance(perspective, Perspectives.PERSPECTIVES["Corfunc"]): 
    10721074            self.checkAnalysisOption(self._workspace.actionCorfunc) 
     1075 
     1076    def saveCustomConfig(self): 
     1077        """ 
     1078        Save the config file based on current session values 
     1079        """ 
     1080        # Load the current file 
     1081        config_content = GuiUtils.custom_config 
     1082 
     1083        changed = self.customSavePaths(config_content) 
     1084        changed = changed or self.customSaveOpenCL(config_content) 
     1085 
     1086        if changed: 
     1087            self.writeCustomConfig(config_content) 
     1088 
     1089    def customSavePaths(self, config_content): 
     1090        """ 
     1091        Update the config module with current session paths 
     1092        Returns True if update was done, False, otherwise 
     1093        """ 
     1094        changed = False 
     1095        # Find load path 
     1096        open_path = GuiUtils.DEFAULT_OPEN_FOLDER 
     1097        defined_path = self.filesWidget.default_load_location 
     1098        if open_path != defined_path: 
     1099            # Replace the load path 
     1100            config_content.DEFAULT_OPEN_FOLDER = defined_path 
     1101            changed = True 
     1102        return changed 
     1103 
     1104    def customSaveOpenCL(self, config_content): 
     1105        """ 
     1106        Update the config module with current session OpenCL choice 
     1107        Returns True if update was done, False, otherwise 
     1108        """ 
     1109        changed = False 
     1110        # Find load path 
     1111        file_value = GuiUtils.SAS_OPENCL 
     1112        session_value = os.environ.get("SAS_OPENCL", "") 
     1113        if file_value != session_value: 
     1114            # Replace the load path 
     1115            config_content.SAS_OPENCL = session_value 
     1116            changed = True 
     1117        return changed 
     1118 
     1119    def writeCustomConfig(self, config): 
     1120        """ 
     1121        Write custom configuration 
     1122        """ 
     1123        from sas import make_custom_config_path 
     1124        path = make_custom_config_path() 
     1125        # Just clobber the file - we already have its content read in 
     1126        with open(path, 'w') as out_f: 
     1127            out_f.write("#Application appearance custom configuration\n") 
     1128            for key, item in config.__dict__.items(): 
     1129                if key[:2] != "__": 
     1130                    if isinstance(item, str): 
     1131                        item = '"' + item + '"' 
     1132                    out_f.write("%s = %s\n" % (key, str(item))) 
     1133        pass # debugger anchor 
  • src/sas/qtgui/Utilities/GuiUtils.py

    rb9ab979 r67346f9  
    151151    DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
    152152    CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
     153    SAS_OPENCL = custom_config.SAS_OPENCL 
    153154    # custom open_path 
    154155    open_folder = custom_config.DEFAULT_OPEN_FOLDER 
     
    171172    CLEANUP_PLOT = False 
    172173    DEFAULT_OPEN_FOLDER = PATH_APP 
     174    SAS_OPENCL = config.SAS_OPENCL 
    173175 
    174176#DEFAULT_STYLE = config.DEFAULT_STYLE 
Note: See TracChangeset for help on using the changeset viewer.