コード例 #1
0
 def __init__(self, plugin_dir, debug=False):
     self.plugin_dir = plugin_dir
     self.spm = VersionedPluginManager()
     self.spm.setPluginPlaces([self.plugin_dir])
     self.spm.collectPlugins()
     self.available_plugins = []
     self.debug = debug
コード例 #2
0
class PluginManager():
    ''' Its purpose is to provide more integrated way to manage modules/ plugins. '''
    def __init__(self, plugin_dir, debug=False):
        self.plugin_dir = plugin_dir
        self.spm = VersionedPluginManager()
        self.spm.setPluginPlaces([self.plugin_dir])
        self.spm.collectPlugins()
        self.available_plugins = []
        self.debug = debug
コード例 #3
0
    def setUp(self):
        """
		init
		"""
        # create the plugin manager
        self.versionedPluginManager = VersionedPluginManager(
            directories_list=[
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             "plugins")
            ],
            plugin_info_ext="version-plugin",
        )
        # load the plugins that may be found
        self.versionedPluginManager.collectPlugins()
        # Will be used later
        self.plugin_info = None
コード例 #4
0
    def __init__(self, bus: Bus, config: Config, graph: Graph):
        self._bus = bus
        self._graph = graph

        logger.debug("action=init paths=%s", config.plugin_paths())
        self._plugin_manager = ConfigurablePluginManager(
            decorated_manager=VersionedPluginManager())
        self._plugin_manager.setPluginPlaces(config.plugin_paths())
        self._plugin_manager.setPluginInfoExtension("plugin")
        self._plugin_manager.setConfigParser(config.parser, config.save)
コード例 #5
0
    def setUp(self):
        """
		init
		"""
        # create the plugin manager
        self.versionedPluginManager = VersionedPluginManager(
            directories_list=[os.path.join(os.path.dirname(os.path.abspath(__file__)), "plugins")],
            plugin_info_ext="version-plugin",
        )
        # load the plugins that may be found
        self.versionedPluginManager.collectPlugins()
        # Will be used later
        self.plugin_info = None
コード例 #6
0
    def _find_parsers(self):
        manager = VersionedPluginManager()
        manager.setPluginPlaces([
            const.RESULTPARSERDIR,
            os.path.join(const.PLUGINDIR, "resultparsers")
        ])
        manager.collectPlugins()

        for plugin in manager.getAllPlugins():
            name = "%s - %s" % (plugin.name, plugin.version)
            self.widgets.parserstore.append([plugin, name])
        self.widgets.parsercombo.set_active(0)
コード例 #7
0
def _setup_plugin_manager(bundled_plugins_dir, plugins_dir, categories):
    plugin_manager = PluginManager(
        plugin_info_ext='genial-plugin',
        directories_list=[bundled_plugins_dir, plugins_dir],
        categories_filter=categories
    )
    plugin_manager = AutoInstallPluginManager(
        plugin_install_dir=plugins_dir,
        decorated_manager=plugin_manager
    )
    plugin_manager = VersionedPluginManager(
        decorated_manager=plugin_manager
    )
    return plugin_manager
コード例 #8
0
class VersionedTestsCase(unittest.TestCase):
    """
    Test the correct loading of a simple plugin as well as basic
    commands.
    """
    
    def setUp(self):
        """
        init
        """
        # create the plugin manager
        self.versionedPluginManager = VersionedPluginManager(
            directories_list=[os.path.join(
					os.path.dirname(os.path.abspath(__file__)),"plugins")],
            plugin_info_ext="version-plugin",
            )
        # load the plugins that may be found
        self.versionedPluginManager.collectPlugins()
        # Will be used later
        self.plugin_info = None

    def plugin_loading_check(self):
        """
        Test if the correct plugin has been loaded.
        """
        if self.plugin_info is None:
            # check nb of categories
            self.assertEqual(len(self.versionedPluginManager.getCategories()),1)
            sole_category = self.versionedPluginManager.getCategories()[0]
            # check the number of plugins (the older versions of the
            # plugins should not be there)
            self.assertEqual(len(self.versionedPluginManager.getPluginsOfCategory(sole_category)),1)
            # older versions of the plugin should be found in the attic
            self.assertEqual(len(self.versionedPluginManager.getPluginsOfCategoryFromAttic(sole_category)),4)
            plugins = self.versionedPluginManager.getPluginsOfCategory(sole_category)
            self.plugin_info = None
            for plugin_info in plugins:
                TEST_MESSAGE("plugin info: %s" % plugin_info)
                if plugin_info.name == "Versioned Plugin":
                    self.plugin_info = plugin_info
                    break
            self.assert_(self.plugin_info)
            # test that the name of the plugin has been correctly defined
            self.assertEqual(self.plugin_info.name,"Versioned Plugin")
            self.assertEqual(sole_category,self.plugin_info.category)
        else:
            self.assert_(True)

    def testLoaded(self):
        """
        Test if the correct plugin has been loaded.
        """
        self.plugin_loading_check()
        sole_category = self.versionedPluginManager.getCategories()[0]
        self.assertEqual(len(self.versionedPluginManager.getLatestPluginsOfCategory(sole_category)),1)
        self.plugin_info = self.versionedPluginManager.getLatestPluginsOfCategory(sole_category)[0]
        TEST_MESSAGE("plugin info: %s" % self.plugin_info)
        # test that the name of the plugin has been correctly defined
        self.assertEqual(self.plugin_info.name,"Versioned Plugin")
        self.assertEqual(sole_category,self.plugin_info.category)
        self.assertEqual("1.2",str(self.plugin_info.version))

        
    def testLatestPluginOfCategory(self):
        self.plugin_loading_check()
        
    def testActivationAndDeactivation(self):
        """
        Test if the activation procedure works.
        """
        self.plugin_loading_check()
        self.assert_(not self.plugin_info.plugin_object.is_activated)
        self.versionedPluginManager.activatePluginByName(self.plugin_info.name,
                                                         self.plugin_info.category)
        self.assert_(self.plugin_info.plugin_object.is_activated)
        self.versionedPluginManager.deactivatePluginByName(self.plugin_info.name,
                                                           self.plugin_info.category)
        self.assert_(not self.plugin_info.plugin_object.is_activated)
        # also check that this is the plugin of the latest version
        # that has been activated (ok the following test is already
        # ensured by the plugin_loading_check method, but this is to
        # make the things clear: the plugin chosen for activation is
        # the one with the latest version)
        self.assertEqual("1.2",str(self.plugin_info.version))
コード例 #9
0
class VersionedTestsCase(unittest.TestCase):
    """
	Test the correct loading of a simple plugin as well as basic
	commands.
	"""
    def setUp(self):
        """
		init
		"""
        # create the plugin manager
        self.versionedPluginManager = VersionedPluginManager(
            directories_list=[
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             "plugins")
            ],
            plugin_info_ext="version-plugin",
        )
        # load the plugins that may be found
        self.versionedPluginManager.collectPlugins()
        # Will be used later
        self.plugin_info = None

    def plugin_loading_check(self):
        """
		Test if the correct plugin has been loaded.
		"""
        if self.plugin_info is None:
            # check nb of categories
            self.assertEqual(len(self.versionedPluginManager.getCategories()),
                             1)
            sole_category = self.versionedPluginManager.getCategories()[0]
            # check the number of plugins (the older versions of the
            # plugins should not be there)
            self.assertEqual(
                len(
                    self.versionedPluginManager.getPluginsOfCategory(
                        sole_category)), 1)
            # older versions of the plugin should be found in the attic
            self.assertEqual(
                len(
                    self.versionedPluginManager.getPluginsOfCategoryFromAttic(
                        sole_category)), 4)
            plugins = self.versionedPluginManager.getPluginsOfCategory(
                sole_category)
            self.plugin_info = None
            for plugin_info in plugins:
                TEST_MESSAGE("plugin info: %s" % plugin_info)
                if plugin_info.name == "Versioned Plugin":
                    self.plugin_info = plugin_info
                    break
            self.assert_(self.plugin_info)
            # test that the name of the plugin has been correctly defined
            self.assertEqual(self.plugin_info.name, "Versioned Plugin")
            self.assertEqual(sole_category, self.plugin_info.category)
        else:
            self.assert_(True)

    def testLoaded(self):
        """
		Test if the correct plugin has been loaded.
		"""
        self.plugin_loading_check()
        sole_category = self.versionedPluginManager.getCategories()[0]
        self.assertEqual(
            len(
                self.versionedPluginManager.getLatestPluginsOfCategory(
                    sole_category)), 1)
        self.plugin_info = self.versionedPluginManager.getLatestPluginsOfCategory(
            sole_category)[0]
        TEST_MESSAGE("plugin info: %s" % self.plugin_info)
        # test that the name of the plugin has been correctly defined
        self.assertEqual(self.plugin_info.name, "Versioned Plugin")
        self.assertEqual(sole_category, self.plugin_info.category)
        self.assertEqual("1.2", str(self.plugin_info.version))

    def testLatestPluginOfCategory(self):
        self.plugin_loading_check()

    def testActivationAndDeactivation(self):
        """
		Test if the activation procedure works.
		"""
        self.plugin_loading_check()
        self.assert_(not self.plugin_info.plugin_object.is_activated)
        self.versionedPluginManager.activatePluginByName(
            self.plugin_info.name, self.plugin_info.category)
        self.assert_(self.plugin_info.plugin_object.is_activated)
        self.versionedPluginManager.deactivatePluginByName(
            self.plugin_info.name, self.plugin_info.category)
        self.assert_(not self.plugin_info.plugin_object.is_activated)
        # also check that this is the plugin of the latest version
        # that has been activated (ok the following test is already
        # ensured by the plugin_loading_check method, but this is to
        # make the things clear: the plugin chosen for activation is
        # the one with the latest version)
        self.assertEqual("1.2", str(self.plugin_info.version))
コード例 #10
0
class VersionedTestsCase(unittest.TestCase):
	"""
	Test the correct loading of a simple plugin as well as basic
	commands.
	"""
	
	def setUp(self):
		"""
		init
		"""
		# create the plugin manager
		self.versionedPluginManager = VersionedPluginManager(
			directories_list=[os.path.join(
					os.path.dirname(os.path.abspath(__file__)),"plugins")],
			plugin_info_ext="version-plugin",
			)
		# load the plugins that may be found
		self.versionedPluginManager.collectPlugins()
		# Will be used later
		self.plugin_info = None

	def plugin_loading_check(self):
		"""
		Test if the correct plugin has been loaded.
		"""
		if self.plugin_info is None:
			# check nb of categories
			self.assertEqual(len(self.versionedPluginManager.getCategories()),1)
			sole_category = self.versionedPluginManager.getCategories()[0]
			# check the number of plugins (the older versions of the
			# plugins should not be there)
			self.assertEqual(len(self.versionedPluginManager.getPluginsOfCategory(sole_category)),1)
			# older versions of the plugin should be found in the attic
			self.assertEqual(len(self.versionedPluginManager.getPluginsOfCategoryFromAttic(sole_category)),4)
			plugins = self.versionedPluginManager.getPluginsOfCategory(sole_category)
			self.plugin_info = None
			for plugin_info in plugins:
				TEST_MESSAGE("plugin info: %s" % plugin_info)
				if plugin_info.name == "Versioned Plugin":
					self.plugin_info = plugin_info
					break
			self.assertTrue(self.plugin_info)
			# test that the name of the plugin has been correctly defined
			self.assertEqual(self.plugin_info.name,"Versioned Plugin")
			self.assertEqual(sole_category,self.plugin_info.category)
		else:
			self.assertTrue(True)

	def testLoaded(self):
		"""
		Test if the correct plugin has been loaded.
		"""
		self.plugin_loading_check()
		sole_category = self.versionedPluginManager.getCategories()[0]
		self.assertEqual(len(self.versionedPluginManager.getLatestPluginsOfCategory(sole_category)),1)
		self.plugin_info = self.versionedPluginManager.getLatestPluginsOfCategory(sole_category)[0]
		TEST_MESSAGE("plugin info: %s" % self.plugin_info)
		# test that the name of the plugin has been correctly defined
		self.assertEqual(self.plugin_info.name,"Versioned Plugin")
		self.assertEqual(sole_category,self.plugin_info.category)
		self.assertEqual("1.2",str(self.plugin_info.version))

		
	def testLatestPluginOfCategory(self):
		self.plugin_loading_check()
		
	def testActivationAndDeactivation(self):
		"""
		Test if the activation procedure works.
		"""
		self.plugin_loading_check()
		self.assertTrue(not self.plugin_info.plugin_object.is_activated)
		self.versionedPluginManager.activatePluginByName(self.plugin_info.name,
														 self.plugin_info.category)
		self.assertTrue(self.plugin_info.plugin_object.is_activated)
		self.versionedPluginManager.deactivatePluginByName(self.plugin_info.name,
														   self.plugin_info.category)
		self.assertTrue(not self.plugin_info.plugin_object.is_activated)
		# also check that this is the plugin of the latest version
		# that has been activated (ok the following test is already
		# ensured by the plugin_loading_check method, but this is to
		# make the things clear: the plugin chosen for activation is
		# the one with the latest version)
		self.assertEqual("1.2",str(self.plugin_info.version))
		
		
	def testDirectActivationAndDeactivation(self):
		"""
		Test if the activation procedure works when directly activating a plugin.
		"""
		self.plugin_loading_check()
		self.assertTrue(not self.plugin_info.plugin_object.is_activated)
		TEST_MESSAGE("plugin object = %s" % self.plugin_info.plugin_object)
		self.plugin_info.plugin_object.activate()
		self.assertTrue(self.plugin_info.plugin_object.is_activated)
		self.plugin_info.plugin_object.deactivate()
		self.assertTrue(not self.plugin_info.plugin_object.is_activated)
		 

	def testAtticConsistencyAfterCategoryFilterUpdate(self):
		"""
		Test that changing the category filer doesn't make the attic inconsistent.
		"""
		self.plugin_loading_check()
		newCategory = "Mouf"
		# Pre-requisite for the test
		previousCategories = self.versionedPluginManager.getCategories()
		self.assertTrue(len(previousCategories) >= 1)
		self.assertTrue(newCategory not in previousCategories)
		# change the category and see what's happening
		self.versionedPluginManager.setCategoriesFilter({newCategory: IPlugin})
		self.versionedPluginManager.collectPlugins()
		for categoryName in previousCategories:
			self.assertRaises(KeyError, self.versionedPluginManager\
							  .getPluginsOfCategory, categoryName)
		self.assertEqual(len(self.versionedPluginManager\
							 .getPluginsOfCategoryFromAttic(newCategory)),4)
コード例 #11
0
class VersionedTestsCase(unittest.TestCase):
    """
	Test the correct loading of a simple plugin as well as basic
	commands.
	"""
    def setUp(self):
        """
		init
		"""
        # create the plugin manager
        self.versionedPluginManager = VersionedPluginManager(
            directories_list=[
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             "plugins")
            ],
            plugin_info_ext="version-plugin",
        )
        # load the plugins that may be found
        self.versionedPluginManager.collectPlugins()
        # Will be used later
        self.plugin_info = None

    def plugin_loading_check(self):
        """
		Test if the correct plugin has been loaded.
		"""
        if self.plugin_info is None:
            # check nb of categories
            self.assertEqual(len(self.versionedPluginManager.getCategories()),
                             1)
            sole_category = self.versionedPluginManager.getCategories()[0]
            # check the number of plugins (the older versions of the
            # plugins should not be there)
            self.assertEqual(
                len(
                    self.versionedPluginManager.getPluginsOfCategory(
                        sole_category)), 1)
            # older versions of the plugin should be found in the attic
            self.assertEqual(
                len(
                    self.versionedPluginManager.getPluginsOfCategoryFromAttic(
                        sole_category)), 4)
            plugins = self.versionedPluginManager.getPluginsOfCategory(
                sole_category)
            self.plugin_info = None
            for plugin_info in plugins:
                TEST_MESSAGE("plugin info: %s" % plugin_info)
                if plugin_info.name == "Versioned Plugin":
                    self.plugin_info = plugin_info
                    break
            self.assertTrue(self.plugin_info)
            # test that the name of the plugin has been correctly defined
            self.assertEqual(self.plugin_info.name, "Versioned Plugin")
            self.assertEqual(sole_category, self.plugin_info.category)
        else:
            self.assertTrue(True)

    def testLoaded(self):
        """
		Test if the correct plugin has been loaded.
		"""
        self.plugin_loading_check()
        sole_category = self.versionedPluginManager.getCategories()[0]
        self.assertEqual(
            len(
                self.versionedPluginManager.getLatestPluginsOfCategory(
                    sole_category)), 1)
        self.plugin_info = self.versionedPluginManager.getLatestPluginsOfCategory(
            sole_category)[0]
        TEST_MESSAGE("plugin info: %s" % self.plugin_info)
        # test that the name of the plugin has been correctly defined
        self.assertEqual(self.plugin_info.name, "Versioned Plugin")
        self.assertEqual(sole_category, self.plugin_info.category)
        self.assertEqual("1.2", str(self.plugin_info.version))

    def testLatestPluginOfCategory(self):
        self.plugin_loading_check()

    def testActivationAndDeactivation(self):
        """
		Test if the activation procedure works.
		"""
        self.plugin_loading_check()
        self.assertTrue(not self.plugin_info.plugin_object.is_activated)
        self.versionedPluginManager.activatePluginByName(
            self.plugin_info.name, self.plugin_info.category)
        self.assertTrue(self.plugin_info.plugin_object.is_activated)
        self.versionedPluginManager.deactivatePluginByName(
            self.plugin_info.name, self.plugin_info.category)
        self.assertTrue(not self.plugin_info.plugin_object.is_activated)
        # also check that this is the plugin of the latest version
        # that has been activated (ok the following test is already
        # ensured by the plugin_loading_check method, but this is to
        # make the things clear: the plugin chosen for activation is
        # the one with the latest version)
        self.assertEqual("1.2", str(self.plugin_info.version))

    def testDirectActivationAndDeactivation(self):
        """
		Test if the activation procedure works when directly activating a plugin.
		"""
        self.plugin_loading_check()
        self.assertTrue(not self.plugin_info.plugin_object.is_activated)
        TEST_MESSAGE("plugin object = %s" % self.plugin_info.plugin_object)
        self.plugin_info.plugin_object.activate()
        self.assertTrue(self.plugin_info.plugin_object.is_activated)
        self.plugin_info.plugin_object.deactivate()
        self.assertTrue(not self.plugin_info.plugin_object.is_activated)

    def testAtticConsistencyAfterCategoryFilterUpdate(self):
        """
		Test that changing the category filer doesn't make the attic inconsistent.
		"""
        self.plugin_loading_check()
        newCategory = "Mouf"
        # Pre-requisite for the test
        previousCategories = self.versionedPluginManager.getCategories()
        self.assertTrue(len(previousCategories) >= 1)
        self.assertTrue(newCategory not in previousCategories)
        # change the category and see what's happening
        self.versionedPluginManager.setCategoriesFilter({newCategory: IPlugin})
        self.versionedPluginManager.collectPlugins()
        for categoryName in previousCategories:
            self.assertRaises(KeyError, self.versionedPluginManager\
                  .getPluginsOfCategory, categoryName)
        self.assertEqual(len(self.versionedPluginManager\
              .getPluginsOfCategoryFromAttic(newCategory)),4)