Changeset b86e4ba in sasview for src/sas/sasgui/guiframe/local_perspectives/data_loader
- Timestamp:
- Aug 16, 2016 8:18:45 AM (8 years ago)
- Branches:
- master, 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- e63cf11
- Parents:
- 18a1f2b (diff), a674d0b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r70308f6c ra674d0b 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.