示例#1
0
 def copy_system_plugins(self):
     """Verify system plugins are copied to the user's plugins folder"""
     # Sample of system plugins to install
     system_plugins = ['medfilter_plugin.py', 'normalize_plugin.py', '__init__.py']
     self.remove_system_files(system_plugins, pathfinder.plugins_path())
     self.model.copy_system_plugins()
     for plugin in system_plugins:
         installed_plugin = os.path.join(pathfinder.plugins_path(), plugin)
         self.assertTrue(os.path.exists(installed_plugin))
示例#2
0
 def test_install_plugin(self):
     """Verify installation of the plugin"""
     self.server_thd.start()
     sample_plugin_url = TestRemoteFetchPluginDialogModel.plugin_url_params(
         'greets_plugin.zip')
     installed_plugin_name = os.path.join(pathfinder.plugins_path(),
                                          'greets_plugin.py')
     plugin_url_params = {
         'url': sample_plugin_url,
         'login': False,
         'username': None,
         'password': None,
         'zip_encrypted': True,
         'zip_password': '******'
     }
     self.model.get_plugin(plugin_url_params)
     successful_installation = self.model.install_plugin()
     self.assertTrue(os.path.exists(installed_plugin_name))
     self.assertTrue(successful_installation)
     # Clean up - attempt to remove the sample plugin if it already exists
     if os.path.exists(installed_plugin_name):
         try:
             os.remove(installed_plugin_name)
         except WindowsError:  # file in use
             return
示例#3
0
def load_plugins():
    """Searches the plugins folder and imports all valid plugins,
    returning a list of the plugins successfully imported as tuples:
    first element is the plugin name (e.g. MyPlugin), second element is
    the class of the plugin."""
    return load_dynamic_modules(pathfinder.plugins_path(),
                                abstractplugin.AbstractPlugin)
示例#4
0
 def test_load_dynamic_modules(self):
     """Verify the main model's dynamic module loading"""
     plugin_list = model.load_dynamic_modules(pathfinder.plugins_path(),
                                              abstractplugin.AbstractPlugin)
     for plugin in plugin_list:
         plugin_instance = plugin[1]
         self.assertTrue(
             issubclass(plugin_instance, abstractplugin.AbstractPlugin))
示例#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 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)
示例#8
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)
 def test_install_plugin(self):
     """Verify installation of the plugin"""
     sample_plugin_url = TestFetchPluginDialogModel.local_plugin('greets_plugin.zip')
     installed_plugin_name = os.path.join(pathfinder.plugins_path(), 'greets_plugin.py')
     plugin_url_params = {'url': sample_plugin_url,
                          'zip_encrypted': True,
                          'zip_password': '******'}
     self.model.get_plugin(plugin_url_params)
     successful_installation = self.model.install_plugin()
     self.assertTrue(os.path.exists(installed_plugin_name))
     self.assertTrue(successful_installation)
     # Clean up - attempt to remove the sample plugin if it already exists
     if os.path.exists(installed_plugin_name):
         try:
             os.remove(installed_plugin_name)
         except WindowsError: # file in use
             return
示例#10
0
 def test_install_plugin(self):
     """Verify install_plugin method correctly installs a plugin; also
     verifies handling of encrypted ZIPs"""
     sample_plugin_url = TestRemotePluginInstaller.plugin_url('greets_plugin.zip')
     installed_plugin_name = os.path.join(pathfinder.plugins_path(), 'greets_plugin.py')
     installer = plugin_installer.RemotePluginInstaller(sample_plugin_url, zip_password='******')
     installer.fetch()
     self.assertTrue(installer.verify_plugin())
     install_success = installer.install_plugin()
     self.assertTrue(os.path.exists(installed_plugin_name))
     self.assertTrue(install_success)
     # Clean up - attempt to remove the sample plugin if it already exists
     if os.path.exists(installed_plugin_name):
         try:
             os.remove(installed_plugin_name)
         except WindowsError: # file in use
             return
示例#11
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
示例#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.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
示例#13
0
 def install_plugin(self):
     """Installs the plugin in the default plugin path.
     Returns True if installation succeeded."""
     plugin_path = pathfinder.plugins_path()
     if self.plugin is not None:
         plugin_zip = UnZipper(self.plugin_contents, self.zip_password)
         if self.verify_plugin():
             plugin_files = [each_file for each_file in plugin_zip.list_contents() if
                             each_file not in self.readme_files]
             for each_file in plugin_files:
                 plugin_zip.extract(each_file, plugin_path)
                 if not os.path.exists(os.path.join(plugin_path, each_file)):
                     module_logger.warning("Plugin installation failed.")
                     return False
         else:
             module_logger.warning("Plugin installation failed - plugin does not conform to spec.")
             return False
     else:
         module_logger.warning("Plugin installation failed - plugin is not set.")
         return False
     return True
示例#14
0
 def copy_system_plugins(cls):
     """Copies plugins that ship with the application to the user's plugins folder."""
     system_plugins_folder = os.path.join(pathfinder.app_path(), 'plugins')
     MainModel.copy_system_files(system_plugins_folder, pathfinder.plugins_path())
示例#15
0
def load_plugins():
    """Searches the plugins folder and imports all valid plugins,
    returning a list of the plugins successfully imported as tuples:
    first element is the plugin name (e.g. MyPlugin), second element is
    the class of the plugin."""
    return load_dynamic_modules(pathfinder.plugins_path(), abstractplugin.AbstractPlugin)
示例#16
0
 def test_plugins_path(self):
     """Verify correct path to plugins"""
     plugin_path = os.path.join(self.user_path, 'plugins')
     self.assertEqual(plugin_path, pathfinder.plugins_path())
示例#17
0
 def test_load_dynamic_modules(self):
     """Verify the main model's dynamic module loading"""
     plugin_list = model.load_dynamic_modules(pathfinder.plugins_path(), abstractplugin.AbstractPlugin)
     for plugin in plugin_list:
         plugin_instance = plugin[1]
         self.assertTrue(issubclass(plugin_instance, abstractplugin.AbstractPlugin))
示例#18
0
 def copy_system_plugins(cls):
     """Copies plugins that ship with the application to the user's plugins folder."""
     system_plugins_folder = os.path.join(pathfinder.app_path(), 'plugins')
     MainModel.copy_system_files(system_plugins_folder,
                                 pathfinder.plugins_path())
 def test_plugins_path(self):
     """Verify correct path to plugins"""
     plugin_path = os.path.join(self.user_path, 'plugins')
     self.assertEqual(plugin_path, pathfinder.plugins_path())