Exemplo n.º 1
0
 def activate_plugin(self, name):
     try:
         if name in get_all_active_plugin_names():
             return "Plugin already in active list"
         if name not in get_all_plugin_names():
             return "I don't know this %s plugin" % name
         activate_plugin_by_name(name)
     except Exception as e:
         logger.exception("Error loading %s" % name)
         return '%s failed to start : %s\n' % (name, e)
     get_plugin_obj_by_name(name).callback_connect()
     return "Plugin %s activated" % name
Exemplo n.º 2
0
 def activate_plugin(self, name):
     try:
         if name in get_all_active_plugin_names():
             return "Plugin already in active list"
         if name not in get_all_plugin_names():
             return "I don't know this %s plugin" % name
         activate_plugin_by_name(name)
     except Exception as e:
         logger.exception("Error loading %s" % name)
         return '%s failed to start : %s\n' % (name, e)
     get_plugin_obj_by_name(name).callback_connect()
     return "Plugin %s activated" % name
Exemplo n.º 3
0
    def status(self, mess, args):
        """ If I am alive I should be able to respond to this one
        """
        all_blacklisted = holder.bot.get_blacklisted_plugin()
        all_loaded = get_all_active_plugin_names()
        all_attempted = sorted([p.name for p in holder.bot.all_candidates])
        plugins_statuses = []
        for name in all_attempted:
            if name in all_blacklisted:
                if name in all_loaded:
                    plugins_statuses.append(('BL', get_plugin_by_name(name).category, name))
                else:
                    plugins_statuses.append(('BU', name))
            elif name in all_loaded:
                plugins_statuses.append(('L', get_plugin_by_name(name).category, name))
            elif get_plugin_obj_by_name(name) is not None:
                plugins_statuses.append(('C', get_plugin_by_name(name).category, name))
            else:
                plugins_statuses.append(('U', name))

        #noinspection PyBroadException
        try:
            from posix import getloadavg

            loads = getloadavg()
        except Exception as _:
            loads = None

        # plugins_statuses = sorted(plugins_statuses, key=lambda c: c[2])
        return {'plugins': plugins_statuses, 'loads': loads, 'gc': gc.get_count()}