Esempio n. 1
0
 def activate_plugin(self, name):
     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_with_version_check(name, self.get_plugin_configuration(name))
     return "Plugin %s activated" % name
Esempio n. 2
0
    def status(self, mess, args):
        """ If I am alive I should be able to respond to this one
        """
        all_blacklisted = self.get_blacklisted_plugin()
        all_loaded = get_all_active_plugin_names()
        all_attempted = sorted([p.name for p in self.all_candidates])
        plugins_statuses = []
        for name in all_attempted:
            if name in all_blacklisted:
                plugins_statuses.append(("B", name))
            elif name in all_loaded:
                plugins_statuses.append(("L", name))
            elif (
                get_plugin_obj_by_name(name) is not None
                and get_plugin_obj_by_name(name).get_configuration_template() is not None
                and self.get_plugin_configuration(name) is None
            ):
                plugins_statuses.append(("C", name))
            else:
                plugins_statuses.append(("E", name))

        try:
            from posix import getloadavg

            loads = getloadavg()
        except Exception as e:
            loads = None
        return {"plugins_statuses": plugins_statuses, "loads": loads, "gc": gc.get_count()}
Esempio n. 3
0
    def status(self, mess, args):
        """ If I am alive I should be able to respond to this one
        """
        all_blacklisted = self.get_blacklisted_plugin()
        all_loaded = get_all_active_plugin_names()
        all_attempted = sorted([p.name for p in self.all_candidates])
        plugins_statuses = []
        for name in all_attempted:
            if name in all_blacklisted:
                if name in all_loaded:
                    plugins_statuses.append(('BL', name))
                else:
                    plugins_statuses.append(('BU', name))
            elif name in all_loaded:
                plugins_statuses.append(('L', name))
            elif get_plugin_obj_by_name(name) is not None and get_plugin_obj_by_name(name).get_configuration_template() is not None and self.get_plugin_configuration(name) is None:
                plugins_statuses.append(('C', name))
            else:
                plugins_statuses.append(('U', name))

        #noinspection PyBroadException
        try:
            from posix import getloadavg

            loads = getloadavg()
        except Exception as _:
            loads = None
        return {'plugins_statuses': plugins_statuses, 'loads': loads, 'gc': gc.get_count()}
Esempio n. 4
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_with_version_check(name, self.get_plugin_configuration(name))
     except Exception, e:
         logging.exception("Error loading %s" % name)
         return "%s failed to start : %s\n" % (name, e)
Esempio n. 5
0
    def unload(self, mess, args):
        """unload a plugin"""
        args = args.strip()
        if not args:
            return ("Please tell me which of the following plugins to reload:\n"
                    "{}".format(self.formatted_plugin_list(active_only=False)))
        if args not in get_all_plugin_names():
            return ("{} isn't a valid plugin name. The current plugins are:\n"
                    "{}".format(args, self.formatted_plugin_list(active_only=False)))
        if args not in get_all_active_plugin_names():
            return "{} is not currently loaded".format(args)

        return self.deactivate_plugin(args)
Esempio n. 6
0
    def formatted_plugin_list(active_only=True):
        """
        Return a formatted, plain-text list of loaded plugins.

        When active_only=True, this will only return plugins which
        are actually active. Otherwise, it will also include inactive
        (blacklisted) plugins.
        """
        if active_only:
            all_plugins = get_all_active_plugin_names()
        else:
            all_plugins = get_all_plugin_names()
        return "\n".join(("• " + plugin for plugin in all_plugins))
Esempio n. 7
0
File: errBot.py Progetto: pol51/err
    def status(self, mess, args):
        """ If I am alive I should be able to respond to this one
        """
        all_blacklisted = self.get_blacklisted_plugin()
        all_loaded = get_all_active_plugin_names()
        all_attempted = sorted([p.name for p in self.all_candidates])

        answer = 'Yes I am alive... With those plugins (E=Error, B=Blacklisted/Unloaded, L=Loaded):\n'
        for name in all_attempted:
            if name in all_blacklisted:
                answer+= '[B] %s\n' % name
            elif name in all_loaded:
                answer+= '[L] %s\n' % name
            else:
                answer+= '[E] %s\n' % name
        answer += '\n\n'
        try:
            from posix import getloadavg
            answer += 'Load %f, %f, %f\n' % getloadavg()
        except Exception as e:
            pass
        answer += 'Objects Generations    0->%i    1->%i    2->%i\n' % gc.get_count()
        return answer
Esempio n. 8
0
 def unload(self, mess, args):
     """unload a plugin"""
     if args not in get_all_active_plugin_names():
         return "%s in not active" % args
     self.blacklist_plugin(args)
     return self.deactivate_plugin(args)
Esempio n. 9
0
 def deactivate_plugin(self, name):
     if name not in get_all_active_plugin_names():
         return "Plugin %s not in active list" % name
     deactivatePluginByName(name)
     return "Plugin %s deactivated" % name
Esempio n. 10
0
 def status(self, mess, args):
     """ If I am alive I should be able to respond to this one
     """
     return 'Yes, I am alive with those plugins :\n' + '\n'.join(get_all_active_plugin_names())