Changeset 729198e in sasview for src/sas/sasgui/guiframe


Ignore:
Timestamp:
Sep 11, 2017 6:55:51 AM (7 years ago)
Author:
lewis
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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ff65d02
Parents:
2d9526d (diff), e2b2473 (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.
Message:

Merge branch 'master' into FixingTicket741

Location:
src/sas/sasgui/guiframe/local_perspectives
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    r235f514 rdcb91cf  
    1111 
    1212from sas.sascalc.dataloader.loader import Loader 
     13from sas.sascalc.dataloader.loader_exceptions import NoKnownLoaderException 
    1314from sas.sasgui.guiframe.plugin_base import PluginBase 
    1415from sas.sasgui.guiframe.events import StatusEvent 
     
    4142APPLICATION_WLIST = config.APPLICATION_WLIST 
    4243 
     44 
    4345class Plugin(PluginBase): 
    4446 
     
    5658        """ 
    5759        # menu for data files 
    58         menu_list = [] 
    5960        data_file_hint = "load one or more data in the application" 
    6061        menu_list = [('&Load Data File(s)', data_file_hint, self.load_data)] 
    6162        gui_style = self.parent.get_style() 
    6263        style = gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 
    63         style1 = gui_style & GUIFRAME.DATALOADER_ON 
    6464        if style == GUIFRAME.MULTIPLE_APPLICATIONS: 
    6565            # menu for data from folder 
     
    102102        self.get_data(file_list) 
    103103 
    104  
    105104    def can_load_data(self): 
    106105        """ 
     
    108107        """ 
    109108        return True 
    110  
    111109 
    112110    def _load_folder(self, event): 
     
    140138        """ 
    141139        if error is not None or str(error).strip() != "": 
    142             dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', 
     140            dial = wx.MessageDialog(self.parent, str(error), 
     141                                    'Error Loading File', 
    143142                                    wx.OK | wx.ICON_EXCLAMATION) 
    144143            dial.ShowModal() 
     
    149148        """ 
    150149        if os.path.isdir(path): 
    151             return [os.path.join(os.path.abspath(path), filename) for filename in os.listdir(path)] 
     150            return [os.path.join(os.path.abspath(path), filename) for filename 
     151                    in os.listdir(path)] 
    152152 
    153153    def _process_data_and_errors(self, item, p_file, output, message): 
     
    178178        for p_file in path: 
    179179            basename = os.path.basename(p_file) 
     180            # Skip files that start with a period 
     181            if basename.startswith("."): 
     182                msg = "The folder included a potential hidden file - %s." \ 
     183                      % basename 
     184                msg += " Do you wish to load this file as data?" 
     185                msg_box = wx.MessageDialog(None, msg, 'Warning', 
     186                                           wx.OK | wx.CANCEL) 
     187                if msg_box.ShowModal() == wx.ID_CANCEL: 
     188                    continue 
    180189            _, extension = os.path.splitext(basename) 
    181190            if extension.lower() in EXTENSIONS: 
     
    213222                info="info") 
    214223 
    215             except: 
    216                 logger.error(sys.exc_value) 
    217  
    218                 error_message = "The Data file you selected could not be loaded.\n" 
    219                 error_message += "Make sure the content of your file" 
    220                 error_message += " is properly formatted.\n" 
    221                 error_message += "When contacting the SasView team, mention the" 
    222                 error_message += " following:\n" 
    223                 error_message += "Error: " + str(sys.exc_info()[1]) 
    224                 file_errors[basename] = [error_message] 
    225                 self.load_update(output=output, message=error_message, info="warning") 
     224            except NoKnownLoaderException as e: 
     225                exception_occurred = True 
     226                logger.error(e.message) 
     227 
     228                error_message = "Loading data failed!\n" + e.message 
     229                self.load_update(output=None, message=e.message, info="warning") 
     230 
     231            except Exception as e: 
     232                exception_occurred = True 
     233                logger.error(e.message) 
     234 
     235                file_err = "The Data file you selected could not be " 
     236                file_err += "loaded.\nMake sure the content of your file" 
     237                file_err += " is properly formatted.\n" 
     238                file_err += "When contacting the SasView team, mention the" 
     239                file_err += " following:\n" 
     240                file_err += e.message 
     241                file_errors[basename] = [file_err] 
    226242 
    227243        if len(file_errors) > 0: 
     
    233249                    error_message += message + "\n" 
    234250                error_message += "\n" 
    235             self.load_update(output=output, message=error_message, info="error") 
    236  
    237         self.load_complete(output=output, message="Loading data complete!", 
    238             info="info") 
     251            if not exception_occurred: # Some data loaded but with errors 
     252                self.load_update(output=output, message=error_message, info="error") 
     253 
     254        if not exception_occurred: # Everything loaded as expected 
     255            self.load_complete(output=output, message="Loading data complete!", 
     256                               info="info") 
     257        else: 
     258            self.load_complete(output=None, message=error_message, info="error") 
     259 
    239260 
    240261    def load_update(self, output=None, message="", info="warning"): 
     
    245266            wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 
    246267                                                  type="progress")) 
    247     def load_complete(self, output, message="", error_message="", path=None, 
    248                       info="warning"): 
    249         """ 
    250          post message to  status bar and return list of data 
    251         """ 
    252         wx.PostEvent(self.parent, StatusEvent(status=message, 
    253                                               info=info, 
     268 
     269    def load_complete(self, output, message="", info="warning"): 
     270        """ 
     271         post message to status bar and return list of data 
     272        """ 
     273        wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 
    254274                                              type="stop")) 
    255         # if error_message != "": 
    256         #    self.load_error(error_message) 
    257         self.parent.add_data(data_list=output) 
     275        if output is not None: 
     276            self.parent.add_data(data_list=output) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py

    r235f514 r2d9526d  
    1414import wx 
    1515import sys 
     16from copy import deepcopy 
    1617from sas.sasgui.guiframe.events import EVT_NEW_PLOT 
    1718from sas.sasgui.guiframe.events import EVT_PLOT_QRANGE 
     
    275276                action_check = True 
    276277            else: 
     278                if action_string == 'update': 
     279                    # Update all existing plots of data with this ID 
     280                    for data in event.plots: 
     281                        for panel in self.plot_panels.values(): 
     282                            if data.id in panel.plots.keys(): 
     283                                plot_exists = True 
     284                                # Pass each panel it's own copy of the data 
     285                                # that's being updated, otherwise things like 
     286                                # colour and line thickness are unintentionally 
     287                                # synced across panels 
     288                                self.update_panel(deepcopy(data), panel) 
     289                    return 
     290                     
    277291                group_id = event.group_id 
    278                 if group_id in self.plot_panels.keys(): 
     292                if group_id in self.plot_panels: 
    279293                    #remove data from panel 
    280294                    if action_string == 'remove': 
Note: See TracChangeset for help on using the changeset viewer.