Changeset 1e56da1 in sasview for src/sas/sasgui


Ignore:
Timestamp:
Sep 15, 2016 8:33:57 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
813220f
Parents:
d4115a55
git-author:
Lewis O'Driscoll <lewis.o'driscoll@…> (08/12/16 11:27:38)
git-committer:
Piotr Rozyczko <rozyczko@…> (09/15/16 08:33:57)
Message:

Show more useful message when loading folder fails (closes #614)

File:
1 edited

Legend:

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

    rfaa3ae7 r1e56da1  
    162162            logging.error("Loader returned an invalid object:\n %s" % str(item)) 
    163163            data_error = True 
    164          
     164 
    165165        data = self.parent.create_gui_data(item, p_file) 
    166166        output[data.id] = data 
     
    176176        data_error = False 
    177177        error_message = "" 
     178 
    178179        for p_file in path: 
    179180            info = "info" 
     
    182183            if extension.lower() in EXTENSIONS: 
    183184                any_error = True 
     185                info = "error" 
    184186                log_msg = "Data Loader cannot " 
    185187                log_msg += "load: %s\n" % str(p_file) 
    186188                log_msg += """Please try to open that file from "open project" """ 
    187                 log_msg += """or "open analysis" menu\n""" 
    188                 error_message = log_msg + "\n" 
     189                log_msg += """or "open analysis" menu\n\n""" 
     190                error_message += log_msg 
    189191                logging.info(log_msg) 
    190192                continue 
     
    210212                logging.error(sys.exc_value) 
    211213                any_error = True 
    212             if any_error or error_message != "": 
    213                 if error_message == "": 
    214                     error = "Error: " + str(sys.exc_info()[1]) + "\n" 
    215                     error += "while loading Data: \n%s\n" % str(basename) 
    216                     error_message += "The data file you selected could not be loaded.\n" 
    217                     error_message += "Make sure the content of your file" 
    218                     error_message += " is properly formatted.\n\n" 
    219                     error_message += "When contacting the SasView team, mention the" 
    220                     error_message += " following:\n%s" % str(error) 
    221                 elif data_error: 
    222                     base_message = "Errors occurred while loading " 
    223                     base_message += "{0}\n".format(basename) 
    224                     base_message += "The data file loaded but with errors.\n" 
    225                     error_message = base_message + error_message 
    226                 else: 
    227                     error_message += "%s\n" % str(p_file) 
     214            if any_error: 
     215                error = "Error: " + str(sys.exc_info()[1]) 
     216                error += " while loading file: %s" % str(basename) 
     217                error_message += "The data file you selected could not be loaded.\n" 
     218                error_message += "Make sure the content of your file" 
     219                error_message += " is properly formatted.\n" 
     220                error_message += "When contacting the SasView team, mention the" 
     221                error_message += " following:\n%s\n\n" % str(error) 
    228222                info = "error" 
    229          
     223            elif data_error: 
     224                base_message = "Errors occurred while loading " 
     225                base_message += "{0}\n".format(basename) 
     226                base_message += "The data file loaded but with errors.\n" 
     227                error_message = base_message + error_message 
     228                info = "error" 
     229 
    230230        if any_error or error_message: 
    231231            self.load_update(output=output, message=error_message, info=info) 
     
    254254        #    self.load_error(error_message) 
    255255        self.parent.add_data(data_list=output) 
    256  
    257  
    258  
Note: See TracChangeset for help on using the changeset viewer.