def on_browse(self, evt): """Handles request to open data folder. If a data file is not selected in the parent, opens the current user's root data folder instead.""" if self.parent.data is None: browse_fldr = pathfinder.data_path() else: browse_fldr = os.path.dirname(self.parent.data) try: open_file.open_file(browse_fldr) except IOError as err: # file not found module_logger.error("Unable to find folder: {0}".format(err)) err_msg = "Unable to find folder '{0}'.\nPlease ensure the folder exists.".format( browse_fldr) err_dlg = wx.MessageDialog(self.parent, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() except OSError as err: # other OS error module_logger.error( "Unable to browse to data folder (OS error): {0}".format(err)) err_msg = "Unable to browse to data folder, error reported was:\n{0}".format( err) err_dlg = wx.MessageDialog(self.parent, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy()
def on_browse_userpath(self, evt): """Handles request to browse to the default userpath""" try: open_file.open_file(pathfinder.user_path()) except IOError: # file not found module_logger.error("User folder {0} not found.".format( pathfinder.user_path())) err_msg = "Unable to find folder '{0}'.\nPlease ensure the folder exists.".format( pathfinder.user_path()) err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() except OSError as err: # other OS error module_logger.error("Unidentified OS error {0}".format(err)) err_msg = "Unable to browse to data folder, error reported was:\n{0}".format( err) err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy()
def on_browse_userpath(self, evt): """Handles request to browse to the default userpath""" try: open_file.open_file(pathfinder.user_path()) except IOError: # file not found module_logger.error("User folder {0} not found.".format(pathfinder.user_path())) err_msg = "Unable to find folder '{0}'.\nPlease ensure the folder exists.".format(pathfinder.user_path()) err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() except OSError as err: # other OS error module_logger.error("Unidentified OS error {0}".format(err)) err_msg = "Unable to browse to data folder, error reported was:\n{0}".format(err) err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy()
def on_browse(self, evt): """Handles request to open data folder. If a data file is not selected in the parent, opens the current user's root data folder instead.""" if self.parent.data is None: browse_fldr = pathfinder.data_path() else: browse_fldr = os.path.dirname(self.parent.data) try: open_file.open_file(browse_fldr) except IOError as err: # file not found module_logger.error("Unable to find folder: {0}".format(err)) err_msg = "Unable to find folder '{0}'.\nPlease ensure the folder exists.".format(browse_fldr) err_dlg = wx.MessageDialog(self.parent, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() except OSError as err: # other OS error module_logger.error("Unable to browse to data folder (OS error): {0}".format(err)) err_msg = "Unable to browse to data folder, error reported was:\n{0}".format(err) err_dlg = wx.MessageDialog(self.parent, message=err_msg, caption="Unable To Open Folder", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy()
def test_filenotfound(self): """Verify IOError raised if file not found""" with self.assertRaises(IOError): open_file.open_file('NO_SUCH_FILE')