Exemple #1
0
def reload_plugins(plugins, *args, **kwargs):
    """
    Module function that'll reload all of the plugins
    """
    config = utils.load_config("Pyhole", kwargs.get("conf_file"))

    # When the modules are reloaded, the meta class will append
    # all of the classes again, so we need to make sure this is empty
    Plugin._plugin_classes = []
    _reset_variables()

    # Now reload all of the plugins
    plugins_to_reload = []
    plugindir = os.path.basename(plugins)

    # Reload existing plugins
    for mod, val in sys.modules.items():
        if plugindir in mod and val and mod != plugindir:
            mod_file = val.__file__
            if not os.path.isfile(mod_file):
                continue
            for p in config.get("plugins", type="list"):
                if plugindir + "." + p == mod:
                    plugins_to_reload.append(mod)

    for p in plugins_to_reload:
        try:
            reload(sys.modules[p])
        except Exception, e:
            # Catch all because this could be many things
            kwargs.get("irc").log.error(e)
            pass
Exemple #2
0
    def __init__(self, irc, conf_file):
        self.irc = irc
        self.name = self.__class__.__name__
        self.disabled = False

        try:
            self.redmine = utils.load_config("Redmine", conf_file)
            self.redmine_domain = self.redmine.get("domain")
            self.redmine_key = self.redmine.get("key")
            self.redmine_url = "https://%s:password@%s" % (
                    self.redmine_key, self.redmine_domain)
        except Exception:
            self.disabled = True
            self.irc.log.error("Unable to load %s configuration." % self.name)
Exemple #3
0
def load_plugins(plugindir, *args, **kwargs):
    """
    Module function that loads plugins from a particular directory
    """
    config = utils.load_config("Pyhole", kwargs.get("conf_file"))

    plugins = os.path.abspath(plugindir)
    plugin_names = config.get("plugins", type="list")

    for p in plugin_names:
        try:
            __import__(os.path.basename(plugindir), globals(), locals(), [p])
        except Exception, e:
            # Catch all because this could be many things
            kwargs.get("irc").log.error(e)
            pass
Exemple #4
0
 def test_load_config(self):
     test_config = utils.load_config("Pyhole", "../pyhole.conf.example")
     self.assertTrue(isinstance(test_config, object))