Example #1
0
def reload_plugins(*args, **kwargs):
    """Module function that'll reload all of the plugins"""
    config = utils.get_config()

    # 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 = "pyhole.plugins"
    local_plugin_dir = utils.get_home_directory() + "plugins"

    # Reload existing plugins
    for mod, val in sys.modules.items():
        l_plugin_path = os.path.join(local_plugin_dir, mod)

        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)

        if local_plugin_dir in str(val):
            plugins_to_reload.append(mod)

    for plugin in plugins_to_reload:
        try:
            reload(sys.modules[plugin])
        except Exception, exc:
            LOG.error(exc)
Example #2
0
def load_user_plugin(plugin, *args, **kwargs):
    """Load a user plugin"""
    sys.path.append(utils.get_home_directory() + "plugins")
    user_plugins = os.listdir(utils.get_directory("plugins"))

    for user_plugin in user_plugins:
        if user_plugin.endswith(".py"):
            user_plugin = user_plugin[:-3]
            if plugin == user_plugin:
                try:
                    __import__(plugin, globals(), locals(), [plugin])
                except Exception, exc:
                    LOG.error(exc)
Example #3
0
def load_user_plugin(plugin, *args, **kwargs):
    """Load a user plugin"""
    sys.path.append(utils.get_home_directory() + "plugins")
    user_plugins = os.listdir(utils.get_directory("plugins"))

    for user_plugin in user_plugins:
        if user_plugin.endswith(".py"):
            user_plugin = user_plugin[:-3]
            if plugin == user_plugin:
                try:
                    __import__(plugin, globals(), locals(), [plugin])
                except Exception, exc:
                    LOG.error(exc)
Example #4
0
def load_user_plugin(plugin, *args, **kwargs):
    """Load a user plugin"""
    sys.path.append(utils.get_home_directory() + "plugins")
    user_plugins = os.listdir(utils.get_directory("plugins"))

    for user_plugin in user_plugins:
        if user_plugin.endswith(".py"):
            user_plugin = user_plugin[:-3]
            if plugin == user_plugin:
                try:
                    __import__(plugin, globals(), locals(), [plugin])
                except Exception, e:
                    # Catch all because this could be many things
                    kwargs.get("irc").log.error(e)
                    pass
Example #5
0
def reload_plugins(*args, **kwargs):
    """Module function that'll reload all of the plugins"""
    config = utils.get_config()

    # Terminate running poll instances
    for plugin in _plugin_instances:
        for attr_name in dir(plugin):
            attr = getattr(plugin, attr_name)
            if getattr(attr, "_is_poll_hook", False):
                # TODO(jk0): Doing this kills the entire process. We need to
                # figure out how to kill it properly. Until this is done,
                # reloading will not work with polls.
                #attr().throw(KeyboardInterrupt)
                pass

    # 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 = "pyhole.plugins"
    local_plugin_dir = utils.get_home_directory() + "plugins"

    # Reload existing plugins
    for mod, val in sys.modules.items():
        l_plugin_path = os.path.join(local_plugin_dir, mod)

        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)

        if local_plugin_dir in str(val):
            plugins_to_reload.append(mod)

    for plugin in plugins_to_reload:
        try:
            reload(sys.modules[plugin])
        except Exception, exc:
            LOG.error(exc)
Example #6
0
def reload_plugins(*args, **kwargs):
    """Module function that'll reload all of the plugins"""
    config = utils.get_config()

    # Terminate running poll instances
    for plugin in _plugin_instances:
        for attr_name in dir(plugin):
            attr = getattr(plugin, attr_name)
            if getattr(attr, "_is_poll_hook", False):
                # TODO(jk0): Doing this kills the entire process. We need to
                # figure out how to kill it properly. Until this is done,
                # reloading will not work with polls.
                #attr().throw(KeyboardInterrupt)
                pass

    # 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 = "pyhole.plugins"
    local_plugin_dir = utils.get_home_directory() + "plugins"

    # Reload existing plugins
    for mod, val in sys.modules.items():
        l_plugin_path = os.path.join(local_plugin_dir, mod)

        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)

        if local_plugin_dir in str(val):
            plugins_to_reload.append(mod)

    for plugin in plugins_to_reload:
        try:
            reload(sys.modules[plugin])
        except Exception, exc:
            LOG.error(exc)