Changeset fe1eb94 in sasview for src/sas/sasgui
- Timestamp:
- Sep 15, 2016 8:33:57 AM (8 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 1de6300
- Parents:
- d6e36e44
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (08/16/16 07:46:41)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (09/15/16 08:33:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r813220f rfe1eb94 170 170 """ 171 171 """ 172 message = "" 173 log_msg = '' 172 file_errors = {} 174 173 output = {} 175 data_error = False 176 error_message = "" 174 exception_occurred = False 177 175 178 176 for p_file in path: 179 file_error = False180 info = "info"181 177 basename = os.path.basename(p_file) 182 178 _, extension = os.path.splitext(basename) 183 179 if extension.lower() in EXTENSIONS: 184 info = "error"185 180 log_msg = "Data Loader cannot " 186 log_msg += "load: %s\n" % str(p_file) 187 log_msg += """Please try to open that file from "open project" """ 188 log_msg += """or "open analysis" menu\n\n""" 189 error_message += log_msg 181 log_msg += "load: {}\n".format(str(p_file)) 182 log_msg += "Please try to open that file from \"open project\"" 183 log_msg += "or \"open analysis\" menu." 190 184 logging.info(log_msg) 185 file_errors[basename] = [log_msg] 191 186 continue 192 187 193 188 try: 194 message = "Loading Data... " + str(p_file) + "\n"195 self.load_update(output=output, message=message, info= info)189 message = "Loading {}...\n".format(p_file) 190 self.load_update(output=output, message=message, info="info") 196 191 temp = self.loader.load(p_file, format) 197 if temp.__class__.__name__ == "list": 198 for item in temp: 199 output, error_message, data_error = \ 200 self._process_data_and_errors(item, 201 p_file, 202 output, 203 error_message) 204 else: 192 if not isinstance(temp, list): 193 temp = [temp] 194 for item in temp: 195 error_message = "" 205 196 output, error_message, data_error = \ 206 self._process_data_and_errors(temp, 207 p_file, 208 output, 209 error_message) 197 self._process_data_and_errors(item, 198 p_file, 199 output, 200 error_message) 201 if data_error: 202 if basename in file_errors.keys(): 203 file_errors[basename] += [error_message] 204 else: 205 file_errors[basename] = [error_message] 206 self.load_update(output=output, 207 message=error_message, info="warning") 208 209 self.load_update(output=output, 210 message="Loaded {}\n".format(p_file), 211 info="info") 212 210 213 except: 211 214 logging.error(sys.exc_value) 212 file_error = True 213 if file_error: 214 error = "Error: " + str(sys.exc_info()[1]) 215 error += " while loading file: %s" % str(basename) 216 error_message += "The data file you selected could not be loaded.\n" 215 216 error_message = "The Data file you selected could not be loaded.\n" 217 217 error_message += "Make sure the content of your file" 218 218 error_message += " is properly formatted.\n" 219 219 error_message += "When contacting the SasView team, mention the" 220 error_message += " following:\n%s\n\n" % str(error) 221 info = "error" 222 elif data_error: 223 base_message = "Errors occurred while loading " 224 base_message += "{0}\n".format(basename) 225 base_message += "The data file loaded but with errors.\n" 226 error_message = base_message + error_message 227 info = "error" 228 229 if error_message != "": 230 self.load_update(output=output, message=error_message, info=info) 231 else: 232 message = "Loading Data Complete! " 233 message += log_msg 234 self.load_complete(output=output, error_message=error_message, 235 message=message, path=path, info='info') 220 error_message += " following:\n" 221 error_message += "Error: " + str(sys.exc_info()[1]) 222 file_errors[basename] = [error_message] 223 self.load_update(output=output, message=error_message, info="warning") 224 225 if len(file_errors) > 0: 226 error_message = "" 227 for filename, error_array in file_errors.iteritems(): 228 error_message += "The following errors occured whilst " 229 error_message += "loading {}:\n".format(filename) 230 for message in error_array: 231 error_message += message + "\n" 232 error_message += "\n" 233 self.load_update(output=output, message=error_message, info="error") 234 235 self.load_complete(output=output, message="Loading data complete!", 236 info="info") 236 237 237 238 def load_update(self, output=None, message="", info="warning"):
Note: See TracChangeset
for help on using the changeset viewer.