Changeset ceaf16e in sasview for prview/perspectives


Ignore:
Timestamp:
Jun 13, 2009 9:43:01 AM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
5cc847c
Parents:
009f827
Message:

prview: slightly better error handling

Location:
prview/perspectives/pr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • prview/perspectives/pr/inversion_panel.py

    ra00ee4c rceaf16e  
    77import wx 
    88import os 
     9import sys 
     10import logging 
    911from sans.guicomm.events import StatusEvent     
    1012from inversion_state import InversionState 
     
    955957            if path and os.path.isfile(path): 
    956958                self.plot_data.SetValue(str(path)) 
    957                 self.manager.show_data(path, reset=True) 
    958                 self._on_pars_changed(None) 
    959              
    960                 # Perform inversion 
    961                 if self.standalone == True: 
    962                     self._on_invert(None) 
     959                try: 
     960                    self.manager.show_data(path, reset=True) 
     961                    self._on_pars_changed(None) 
     962                 
     963                    # Perform inversion 
     964                    if self.standalone == True: 
     965                        self._on_invert(None) 
     966                except: 
     967                    # Invalid data 
     968                    logging.error("InversionControl._change_file: %s" % sys.exc_value)                     
    963969 
    964970class HelpDialog(wx.Dialog): 
  • prview/perspectives/pr/pr.py

    r0d88a09 rceaf16e  
    412412        # Use data loader to load file 
    413413        dataread = Loader().load(path) 
     414         
     415        # Notify the user if we could not read the file 
     416        if dataread is None: 
     417            raise RuntimeError, "Invalid data" 
     418             
    414419        x = None 
    415420        y = None 
     
    827832            @param reset: if True all other plottables will be cleared 
    828833        """ 
    829          
    830          
    831834        if path is not None: 
    832835            try: 
    833836                pr = self._create_file_pr(path) 
    834                  
    835                 # If the file contains nothing, just return 
    836                 if pr is None: 
    837                     return 
    838                  
    839                 self.pr = pr 
    840             except:   
    841                 wx.PostEvent(self.parent, StatusEvent(status=sys.exc_value)) 
    842                 return 
     837            except: 
     838                status="Problem reading data: %s" % sys.exc_value 
     839                wx.PostEvent(self.parent, StatusEvent(status=status)) 
     840                raise RuntimeError, status 
     841                 
     842            # If the file contains nothing, just return 
     843            if pr is None: 
     844                raise RuntimeError, "Loaded data is invalid" 
     845             
     846            self.pr = pr 
    843847               
    844848        # Make a plot of I(q) data 
     
    925929            @param path: path of the file to read in  
    926930        """ 
     931        # Sanity check 
     932        if self.current_plottable is None: 
     933            msg = "Please load a valid data set before proceeding." 
     934            wx.PostEvent(self.parent, StatusEvent(status=msg))   
     935            return None    
     936         
    927937        # Get the data from the chosen data set and perform inversion 
    928938        pr = Invertor() 
     
    10311041                #TODO: refactor this into a proper status handling 
    10321042                wx.PostEvent(self.parent, StatusEvent(status='')) 
    1033                 x, y, err = self.load(path) 
     1043                try: 
     1044                    x, y, err = self.load(path) 
     1045                except: 
     1046                    message = "Could not read the data file: %s" % path 
     1047                    wx.PostEvent(self.parent, StatusEvent(status=message)) 
     1048                    return None 
    10341049                 
    10351050                # If the file contains no data, just return 
    1036                 #TODO: clean this up: we need a way to recognize that not all P(r) files are data 
    10371051                if x is None: 
     1052                    message = "The loaded file contains no data" 
     1053                    wx.PostEvent(self.parent, StatusEvent(status=message)) 
    10381054                    return None 
    10391055             
Note: See TracChangeset for help on using the changeset viewer.