Example #1
0
 def reloadPluginType(self, type):
     """ Reloads plugins of a given type and updates their information
     """
     Plugins.reloadPluginsByType(type)
     if self.hasPluginType(type, mustBeActive = False):
         self.getPluginType(type).updateInfo()
     else:
         raise PluginError("Error while trying to reload plugins of the type: " + type + ". Plugins of the type " + type + "do not exist")
Example #2
0
    def updateInfo(self):
        """ This method will update the information in the DB about this plugin type.
            It will call the lower-level layer ( MaKaC/plugins/__init__.py ) to retrieve
            information about its plugins, its options, etc.
        """

        #until we detect them, the plugins of this given Type are marked as present
        for plugin in self.getPluginList(includeNonPresent=True,
                                         includeNonActive=True):
            plugin.setPresent(False)

        #we get the list of modules (plugins) of this type
        pluginModules = Plugins.getPluginsByType(self.getName())

        #we loop through the plugins
        for pluginModule in pluginModules:
            if hasattr(pluginModule, "ignore") and pluginModule.ignore:
                continue

            #if it already existed, we mark it as present
            pluginName = pluginModule.pluginName
            if self.hasPlugin(pluginName):
                p = self.getPlugin(pluginName)
                if hasattr(pluginModule, "pluginDescription"):
                    p.setDescription(pluginModule.pluginDescription)
                p.setPresent(True)

            #if it didn't exist, we create it
            else:
                if hasattr(pluginModule, "pluginDescription"):
                    description = pluginModule.pluginDescription
                else:
                    description = None

                p = Plugin(pluginName, pluginModule.__name__, self,
                           description)
                self.addPlugin(p)

            if hasattr(pluginModule, "testPlugin") and pluginModule.testPlugin:
                p.setTestPlugin(pluginModule.testPlugin)

            if hasattr(pluginModule, "options") and hasattr(
                    pluginModule.options, "globalOptions"):
                p.updateAllOptions(pluginModule.options.globalOptions)

            if hasattr(pluginModule, "actions") and hasattr(
                    pluginModule.actions, "pluginActions"):
                p.updateAllActions(pluginModule.actions.pluginActions)

        retrievedPluginTypeOptions = Plugins.getOptionsByType(self.getName())
        self.updateAllOptions(retrievedPluginTypeOptions)

        retrievedPluginTypeActions = Plugins.getActionsByType(self.getName())
        self.updateAllActions(retrievedPluginTypeActions)

        self.__description = Plugins.getDescriptionByType(self.getName())

        self._visible = Plugins.getIsVisibleType(self.getName())
Example #3
0
 def reloadPluginType(self, type):
     """ Reloads plugins of a given type and updates their information
     """
     Plugins.reloadPluginsByType(type)
     if self.hasPluginType(type, mustBeActive=False):
         self.getPluginType(type).updateInfo()
     else:
         raise PluginError(
             "Error while trying to reload plugins of the type: " + type +
             ". Plugins of the type " + type + "do not exist")
Example #4
0
    def updateInfo(self):
        """ This method will update the information in the DB about this plugin type.
            It will call the lower-level layer ( MaKaC/plugins/__init__.py ) to retrieve
            information about its plugins, its options, etc.
        """
        
        #until we detect them, the plugins of this given Type are marked as present
        for plugin in self.getPluginList(includeNonPresent = True, includeNonActive = True):
            plugin.setPresent(False)

        #we get the list of modules (plugins) of this type
        pluginModules = Plugins.getPluginsByType(self.getName())

        #we loop through the plugins
        for pluginModule in pluginModules:
            if hasattr(pluginModule, "ignore") and pluginModule.ignore:
                continue
            
            #if it already existed, we mark it as present
            pluginName = pluginModule.pluginName
            if self.hasPlugin(pluginName):
                p = self.getPlugin(pluginName)
                if hasattr(pluginModule, "pluginDescription"):
                    p.setDescription(pluginModule.pluginDescription)
                p.setPresent(True)

            #if it didn't exist, we create it
            else:
                if hasattr(pluginModule, "pluginDescription"):
                    description = pluginModule.pluginDescription
                else:
                    description = None
                
                p = Plugin(pluginName, pluginModule.__name__, self, description)
                self.addPlugin(p)
                
            if hasattr(pluginModule, "testPlugin") and pluginModule.testPlugin:
                p.setTestPlugin(pluginModule.testPlugin)
                
            if hasattr(pluginModule, "options") and hasattr(pluginModule.options, "globalOptions"):
                p.updateAllOptions(pluginModule.options.globalOptions)
                
            if hasattr(pluginModule, "actions") and hasattr(pluginModule.actions, "pluginActions"):
                p.updateAllActions(pluginModule.actions.pluginActions)

        
        retrievedPluginTypeOptions = Plugins.getOptionsByType(self.getName())
        self.updateAllOptions(retrievedPluginTypeOptions)
        
        retrievedPluginTypeActions = Plugins.getActionsByType(self.getName())
        self.updateAllActions(retrievedPluginTypeActions)
        
        self.__description = Plugins.getDescriptionByType(self.getName())
        
        self._visible = Plugins.getIsVisibleType(self.getName())
Example #5
0
 def call(self):
     actionClassName = self.__name[0].upper() + self.__name[1:] + "Action"
     if isinstance(self.__owner, Plugin):
         clazz = getattr(self.__owner.getModule().actions, actionClassName)
     else: #instance of PluginType
         clazz = getattr(Plugins.getPluginTypeActionModuleByName(self.__owner.getName()), actionClassName )
     clazz(self).call()
Example #6
0
 def call(self):
     actionClassName = self.__name[0].upper() + self.__name[1:] + "Action"
     if isinstance(self.__owner, Plugin):
         clazz = getattr(self.__owner.getModule().actions, actionClassName)
     else:  #instance of PluginType
         clazz = getattr(
             Plugins.getPluginTypeActionModuleByName(
                 self.__owner.getName()), actionClassName)
     clazz(self).call()
Example #7
0
 def updateAllPluginInfo(self):
     """ Updates the info about plugins in the DB
         We must keep if plugins are active or not even between reloads
         and even if plugins are removed from the file system (they may
         be present again later)
     """
     for pt in self.getPluginTypes(includeNonPresent = True):
         pt.setPresent(False)
     
     types = Plugins.getTypeList()
     for type in types:
         
         if self.hasPluginType(type, mustBePresent = False, mustBeActive = False):
             pluginType = self.getPluginType(type)
             pluginType.setPresent(True)
         else:
             pluginType = PluginType(type) 
             self.add(pluginType)
         
         pluginType.updateInfo()
Example #8
0
    def updateAllPluginInfo(self):
        """ Updates the info about plugins in the DB
            We must keep if plugins are active or not even between reloads
            and even if plugins are removed from the file system (they may
            be present again later)
        """
        for pt in self.getPluginTypes(includeNonPresent=True):
            pt.setPresent(False)

        types = Plugins.getTypeList()
        for type in types:

            if self.hasPluginType(type,
                                  mustBePresent=False,
                                  mustBeActive=False):
                pluginType = self.getPluginType(type)
                pluginType.setPresent(True)
            else:
                pluginType = PluginType(type)
                self.add(pluginType)

            pluginType.updateInfo()
Example #9
0
 def reloadAllPlugins(self):
     """ Reloads all plugins and updates their information
     """
     Plugins.reloadPlugins()
     self.updateAllPluginInfo()
Example #10
0
 def loadAllPlugins(self):
     """ Initially loads all plugins and stores their information
     """
     Plugins.loadPlugins()
     self.updateAllPluginInfo()
Example #11
0
 def getModule(self):
     return Plugins.getPluginByTypeAndName(self.getType(), self.getName())
Example #12
0
 def getModule(self):
     return Plugins.getPluginByTypeAndName(self.getType(), self.getName())
Example #13
0
 def reloadAllPlugins(self):
     """ Reloads all plugins and updates their information
     """
     Plugins.reloadPlugins()
     self.updateAllPluginInfo()
Example #14
0
 def loadAllPlugins(self):
     """ Initially loads all plugins and stores their information
     """
     Plugins.loadPlugins()
     self.updateAllPluginInfo()