Changeset 759a8ab in sasview for src/sas/sasgui/guiframe/local_perspectives
- Timestamp:
- Aug 29, 2017 5:30:45 PM (7 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 25a42f99
- Parents:
- 7c64911 (diff), f001bc9 (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
r914ba0a r759a8ab 11 11 12 12 from sas.sascalc.dataloader.loader import Loader 13 from sas.sascalc.dataloader.loader_exceptions import NoKnownLoaderException 13 14 14 15 from sas.sasgui import get_local_config … … 26 27 APPLICATION_WLIST = config.APPLICATION_WLIST 27 28 29 28 30 class Plugin(PluginBase): 29 31 … … 41 43 """ 42 44 # menu for data files 43 menu_list = []44 45 data_file_hint = "load one or more data in the application" 45 46 menu_list = [('&Load Data File(s)', data_file_hint, self.load_data)] 46 47 gui_style = self.parent.get_style() 47 48 style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 48 style1 = gui_style & GUIFRAME.DATALOADER_ON49 49 if style == GUIFRAME.MULTIPLE_APPLICATIONS: 50 50 # menu for data from folder … … 87 87 self.get_data(file_list) 88 88 89 90 89 def can_load_data(self): 91 90 """ … … 93 92 """ 94 93 return True 95 96 94 97 95 def _load_folder(self, event): … … 125 123 """ 126 124 if error is not None or str(error).strip() != "": 127 dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', 125 dial = wx.MessageDialog(self.parent, str(error), 126 'Error Loading File', 128 127 wx.OK | wx.ICON_EXCLAMATION) 129 128 dial.ShowModal() … … 134 133 """ 135 134 if os.path.isdir(path): 136 return [os.path.join(os.path.abspath(path), filename) for filename in os.listdir(path)] 135 return [os.path.join(os.path.abspath(path), filename) for filename 136 in os.listdir(path)] 137 137 138 138 def _process_data_and_errors(self, item, p_file, output, message): … … 163 163 for p_file in path: 164 164 basename = os.path.basename(p_file) 165 # Skip files that start with a period 166 if basename.startswith("."): 167 msg = "The folder included a potential hidden file - %s." \ 168 % basename 169 msg += " Do you wish to load this file as data?" 170 msg_box = wx.MessageDialog(None, msg, 'Warning', 171 wx.OK | wx.CANCEL) 172 if msg_box.ShowModal() == wx.ID_CANCEL: 173 continue 165 174 _, extension = os.path.splitext(basename) 166 175 if extension.lower() in EXTENSIONS: … … 198 207 info="info") 199 208 200 except: 201 logger.error(sys.exc_value) 202 203 error_message = "The Data file you selected could not be loaded.\n" 204 error_message += "Make sure the content of your file" 205 error_message += " is properly formatted.\n" 206 error_message += "When contacting the SasView team, mention the" 207 error_message += " following:\n" 208 error_message += "Error: " + str(sys.exc_info()[1]) 209 file_errors[basename] = [error_message] 210 self.load_update(output=output, message=error_message, info="warning") 209 except NoKnownLoaderException as e: 210 exception_occurred = True 211 logger.error(e.message) 212 213 error_message = "Loading data failed!\n" + e.message 214 self.load_update(output=None, message=e.message, info="warning") 215 216 except Exception as e: 217 exception_occurred = True 218 logger.error(e.message) 219 220 file_err = "The Data file you selected could not be " 221 file_err += "loaded.\nMake sure the content of your file" 222 file_err += " is properly formatted.\n" 223 file_err += "When contacting the SasView team, mention the" 224 file_err += " following:\n" 225 file_err += e.message 226 file_errors[basename] = [file_err] 211 227 212 228 if len(file_errors) > 0: … … 218 234 error_message += message + "\n" 219 235 error_message += "\n" 220 self.load_update(output=output, message=error_message, info="error") 221 222 self.load_complete(output=output, message="Loading data complete!", 223 info="info") 236 if not exception_occurred: # Some data loaded but with errors 237 self.load_update(output=output, message=error_message, info="error") 238 239 if not exception_occurred: # Everything loaded as expected 240 self.load_complete(output=output, message="Loading data complete!", 241 info="info") 242 else: 243 self.load_complete(output=None, message=error_message, info="error") 244 224 245 225 246 def load_update(self, output=None, message="", info="warning"): … … 230 251 wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 231 252 type="progress")) 232 def load_complete(self, output, message="", error_message="", path=None, 233 info="warning"): 234 """ 235 post message to status bar and return list of data 236 """ 237 wx.PostEvent(self.parent, StatusEvent(status=message, 238 info=info, 253 254 def load_complete(self, output, message="", info="warning"): 255 """ 256 post message to status bar and return list of data 257 """ 258 wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 239 259 type="stop")) 240 # if error_message != "": 241 # self.load_error(error_message) 242 self.parent.add_data(data_list=output) 260 if output is not None: 261 self.parent.add_data(data_list=output)
Note: See TracChangeset
for help on using the changeset viewer.