示例#1
0
 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()
示例#2
0
 def verify_userpath(self):
     """Ensures the user's data folder is available"""
     if not os.path.exists(pathfinder.user_path()):
         module_logger.info("Created user data folder")
         self.set_userpath()
     self.model.check_user_path()
     self.model.copy_system_plugins()
示例#3
0
 def verify_userpath(self):
     """Ensures the user's data folder is available"""
     if not os.path.exists(pathfinder.user_path()):
         module_logger.info("Created user data folder")
         self.set_userpath()
     self.model.check_user_path()
     self.model.copy_system_plugins()
示例#4
0
 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()
示例#5
0
 def check_user_path(self):
     """Verify user data folders were created"""
     data_folders = [pathfinder.user_path(), pathfinder.data_path(),
                     pathfinder.thumbnails_path(), pathfinder.gates_path(),
                     pathfinder.plugins_path(), pathfinder.podmodels_path(),
                     pathfinder.colormaps_path(), pathfinder.batchoutput_path()]
     self.model.check_user_path()
     for folder in data_folders:
         self.assertTrue(os.path.exists(folder))
示例#6
0
 def check_user_path(self):
     """Verify user data folders were created"""
     data_folders = [pathfinder.user_path(), pathfinder.data_path(),
                     pathfinder.thumbnails_path(), pathfinder.gates_path(),
                     pathfinder.plugins_path(), pathfinder.podmodels_path(),
                     pathfinder.adamodels_path(), pathfinder.colormaps_path(),
                     pathfinder.batchoutput_path()]
     self.model.check_user_path()
     for folder in data_folders:
         self.assertTrue(os.path.exists(folder))
示例#7
0
 def set_userpath(self):
     """ Prompts user to set a default path for storing user data """
     try:
         current_user_path = pathfinder.user_path()
         path_dlg = wx.DirDialog(parent=self.view.parent, message="Please specify a data folder",
                                 defaultPath=current_user_path)
         if path_dlg.ShowModal() == wx.ID_OK:
             new_user_path = path_dlg.GetPath()
             self.model.migrate_user_path(new_user_path)
             self.refresh_data()
     finally:
         path_dlg.Destroy()
示例#8
0
 def test_migrate_user_path(self):
     """Verify migration of the user's data folder"""
     current_user_path = pathfinder.user_path()
     temp_user_path = tempfile.mkdtemp()
     self.model.migrate_user_path(temp_user_path)
     self.check_user_path()
     self.copy_system_plugins()
     self.model.migrate_user_path(current_user_path)
     try:
         shutil.rmtree(temp_user_path)
     except WindowsError: # folder in use
         pass
示例#9
0
 def set_userpath(self):
     """ Prompts user to set a default path for storing user data """
     try:
         current_user_path = pathfinder.user_path()
         path_dlg = wx.DirDialog(parent=self.view, message="Please specify a data folder",
                                 defaultPath=current_user_path)
         if path_dlg.ShowModal() == wx.ID_OK:
             new_user_path = path_dlg.GetPath()
             self.model.migrate_user_path(new_user_path)
             self.refresh_data()
     finally:
         path_dlg.Destroy()
示例#10
0
 def check_user_path(cls):
     """Verify that user data folders exist.  Creates
     any missing folders."""
     user_folder = pathfinder.user_path()
     data_folder = pathfinder.data_path()
     thumbnail_folder = pathfinder.thumbnails_path()
     plugins_folder = pathfinder.plugins_path()
     podmodels_folder = pathfinder.podmodels_path()
     adamodels_folder = pathfinder.adamodels_path()
     gates_folder = pathfinder.gates_path()
     colormaps_folder = pathfinder.colormaps_path()
     batch_folder = pathfinder.batchoutput_path()
     for fldr in (user_folder, data_folder, thumbnail_folder, plugins_folder, podmodels_folder, gates_folder,
         adamodels_folder, colormaps_folder, batch_folder):
         if not os.path.exists(fldr):
             os.makedirs(fldr)
示例#11
0
 def check_user_path(cls):
     """Verify that user data folders exist.  Creates
     any missing folders."""
     user_folder = pathfinder.user_path()
     data_folder = pathfinder.data_path()
     thumbnail_folder = pathfinder.thumbnails_path()
     plugins_folder = pathfinder.plugins_path()
     podmodels_folder = pathfinder.podmodels_path()
     gates_folder = pathfinder.gates_path()
     colormaps_folder = pathfinder.colormaps_path()
     batch_folder = pathfinder.batchoutput_path()
     for fldr in (user_folder, data_folder, thumbnail_folder,
                  plugins_folder, podmodels_folder, gates_folder,
                  colormaps_folder, batch_folder):
         if not os.path.exists(fldr):
             os.makedirs(fldr)
示例#12
0
def deleted_user_path():
    """Utility function to delete empty folders in the user data folders,
    used to verify that MainModel will recreate missing folders as required.
    Returns a list of folders successfully deleted or None if no folders
    were deleted."""
    data_folders = [pathfinder.user_path(), pathfinder.data_path(), pathfinder.thumbnails_path(),
                    pathfinder.plugins_path(), pathfinder.colormaps_path()]
    deleted_folders = []
    for folder in data_folders:
        exists_and_empty = os.path.exists(folder) and os.listdir(folder) == []
        if exists_and_empty:
            try:
                os.rmdir(folder)
                deleted_folders.append(folder)
            except WindowsError: # folder in use (Explorer, cmd, etc.)
                pass
    if deleted_folders:
        return deleted_folders
    return None
示例#13
0
def deleted_user_path():
    """Utility function to delete empty folders in the user data folders,
    used to verify that MainModel will recreate missing folders as required.
    Returns a list of folders successfully deleted or None if no folders
    were deleted."""
    data_folders = [pathfinder.user_path(), pathfinder.data_path(), pathfinder.thumbnails_path(),
                    pathfinder.plugins_path(), pathfinder.podmodels_path(), pathfinder.adamodels_path(),
                    pathfinder.colormaps_path()]
    deleted_folders = []
    for folder in data_folders:
        exists_and_empty = os.path.exists(folder) and os.listdir(folder) == []
        if exists_and_empty:
            try:
                os.rmdir(folder)
                deleted_folders.append(folder)
            except WindowsError: # folder in use (Explorer, cmd, etc.)
                pass
    if deleted_folders:
        return deleted_folders
    return None
示例#14
0
 def test_user_path(self):
     """Verify pathfinder reports the correct path for storing user data"""
     self.assertEqual(self.user_path, pathfinder.user_path())
 def test_user_path(self):
     """Verify pathfinder reports the correct path for storing user data"""
     self.assertEqual(self.user_path, pathfinder.user_path())