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()}
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()}
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)) #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() }
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()}
def status_load(self, _, args): """ shows the load status """ try: from posix import getloadavg loads = getloadavg() except Exception: loads = None return {'loads': loads}
def status_load(self, mess, args): """ shows the load status """ try: from posix import getloadavg loads = getloadavg() except Exception: loads = None return {'loads': loads}
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