Return all the stats to be exported (list).
        Default behavor is to export all the stat
        if plugin_list is provided, only export stats of given plugin (list)
349943
def getAllExportsAsDict(self, plugin_list=None):
        
        if plugin_list is None:
            # All plugins should be exported
            plugin_list = self._plugins
        return {p: self._plugins[p].get_export() for p in plugin_list}
859774
def get(self, thread=None, plugin=None):
        
        if plugin is not None:
            if thread is None:
                threads_list = {}
                for key in self.threads.keys():
                    if self.threads[key].plugin == plugin:
                        threads_list[key] = self.threads[key]
                return threads_list
            else:
                if thread in self.threads.keys():
                    if self.threads[thread].plugin == plugin:
                        return self.threads[thread]
                    else:
                        return None
                else:
                    return None
        else:
            if thread is None:
                return self.threads
            else:
                if thread in self.threads.keys():
                    return self.threads[thread]
                else:
                    return None
540870
def export_capacities(self):
        
        return [export for cls in getmro(type(self)) if hasattr(cls, "EXPORT_TO") for export in cls.EXPORT_TO]
462981
def plugin_counts(self):
        
        ret = {
            'total': 0,
        }

        # As ususal, we need data before we can actually do anything ;)
        data = self.raw_query('plugin', 'init')

        # For backwards compatability purposes, we will be handling this a bit
        # differently than I would like.  We are going to check to see if each
        # value exists and override the default value of 0.  The only value that
        # I know existed in bost 4.2 and 4.4 is pluginCount, the rest aren't
        # listed in the API docs, however return back from my experimentation.
        ret['total'] = data['pluginCount']

        if 'lastUpdates' in data:
            for item in ['active', 'passive', 'compliance', 'custom', 'event']:
                itemdata = {}
                if item in data['lastUpdates']:
                    itemdata = data['lastUpdates'][item]
                if item in data:
                    itemdata['count'] = data[item]
                else:
                    itemdata['count'] = 0

                ret[item] = itemdata
        return ret
1158845
def get_summary(self):
        
        func_summaries = [f.get_summary() for f in self.functions]
        modif_summaries = [f.get_summary() for f in self.modifiers]
        return (self.name, [str(x) for x in self.inheritance], [str(x) for x in self.variables], func_summaries, modif_summaries)
1110623
def get_stats(self, pattern):
        
        if not self.cache:
            return
        key_list = self.cache.get(Conf.Q_STAT)
        if not key_list or len(key_list) == 0:
            return []
        stats = []
        for key in key_list:
            stat = self.cache.get(key)
            if stat:
                stats.append(stat)
            else:
                key_list.remove(key)
        self.cache.set(Conf.Q_STAT, key_list)
        return stats
441301
def get_plugins(**kwargs):
    
    
    plugins = []
    plugin_paths = []
    
    #Look in directory or set of directories for
    #plugins
    
    base_plugin_dir = config.get('plugin', 'default_directory')
    plugin_xsd_path = config.get('plugin', 'plugin_xsd_path')

    base_plugin_dir_contents = os.listdir(base_plugin_dir)
    for directory in base_plugin_dir_contents:
        #ignore hidden files
        if directory[0] == '.' or directory == 'xml':
            continue

        #Is this a file or a directory? If it's a directory, it's a plugin.
        path = os.path.join(base_plugin_dir, directory)
        if os.path.isdir(path):
            plugin_paths.append(path)
   

    #For each plugin, get its details (an XML string)
    
    #Retrieve the xml schema for validating the XML to make sure
    #what is being provided  to the IU is correct.
    xmlschema_doc = etree.parse(plugin_xsd_path)
                    
    xmlschema = etree.XMLSchema(xmlschema_doc)
    
    #Get the xml description file from the plugin directory. If there
    #is no xml file, the plugin in unusable.
    for plugin_dir in plugin_paths:
        full_plugin_path = os.path.join(plugin_dir, 'trunk')
        
        dir_contents = os.listdir(full_plugin_path)
        #look for a plugin.xml file in the plugin directory 
        for file_name in dir_contents:
            file_path = os.path.join(full_plugin_path, file_name)
            if file_name == 'plugin.xml':
                
                f = open(file_path, 'r')
                
                #validate the xml using the xml schema for defining
                #plugin details
                try:
                    y = open(file_path, 'r')
                    
                    xml_tree = etree.parse(y)

                    xmlschema.assertValid(xml_tree)
                   
                    plugins.append(etree.tostring(xml_tree))
                except Exception as e:
                    log.critical("Schema %s did not validate! (error was %s)"%(file_name, e))

                break
        else:
            log.warning("No xml plugin details found for %s. Ignoring", plugin_dir)

    return plugins
979087
def _api(self, plugin):
        
        response.content_type = 'application/json; charset=utf-8'

        if plugin not in self.plugins_list:
            abort(400, "Unknown plugin %s (available plugins: %s)" % (plugin, self.plugins_list))

        # Update the stat
        self.__update__()

        try:
            # Get the JSON value of the stat ID
            statval = self.stats.get_plugin(plugin).get_stats()
        except Exception as e:
            abort(404, "Cannot get plugin %s (%s)" % (plugin, str(e)))
        return statval
236156
def tryImportAllPlugins(self):
        
        logger.debug("Importing plugins: {}".format(self))
        for tabNr in range(self.tabWidget.count()):
            tab = self.tabWidget.widget(tabNr)
            tab.tryImportAllPlugins()
368843
def data(self):
        
        d = {}
        for key in self._data:
            if key == "plugins":
                d[key] = self.plugins.data()
            else:
                try:
                    d[key] = getattr(self, key)
                except AttributeError:
                    pass  # unknown key, just leave it unchanged
        return d
466002
def update(self, stats):
        """"""

        if self.generate_every != 0 and self._timer.finished():
            self.args.generate_graph = True
            self._timer.reset()

        if not self.args.generate_graph:
            return

        plugins = stats.getPluginsList()
        for plugin_name in plugins:
            plugin = stats._plugins[plugin_name]
            if plugin_name in self.plugins_to_export():
                self.export(plugin_name, plugin.get_export_history())

        logger.info("Graphs created in the folder {}".format(self.path))
        self.args.generate_graph = False
1062352
def get_all_tep(self):
        
        teps = {}
        for p in self.get_enabled_plugins:
            for e, v in p["plugin_tep"].items():
                tep = teps.get(e, dict())
                tepHF = tep.get("HTMLFile", [])
                tepHS = tep.get("HTMLString", [])
                tepHF += [s for f, s in v.items() if f == "HTMLFile"]
                tepHS += [s for f, s in v.items() if f == "HTMLString"]
                teps[e] = dict(HTMLFile=tepHF, HTMLString=tepHS)
        return teps
798369
def init(self):
        """"""
        if not self.export_enable:
            return None
        # Build the RESTful URL where the stats will be posted
        url = '{}://{}:{}{}'.format(self.protocol,
                                    self.host,
                                    self.port,
                                    self.path)
        logger.info(
            "Stats will be exported to the RESTful endpoint {}".format(url))
        return url
1097503
def get_stats(self, obj, stat_name):
        
        return [int(v) for v in self.send_command_return(obj, stat_name, '?').split()]
715445
def export(self, name, columns, points):
        """"""
        if name == self.plugins_to_export()[0] and self.buffer != {}:
            # One complete loop have been done
            logger.debug("Export stats ({}) to RESTful endpoint ({})".format(listkeys(self.buffer),
                                                                             self.client))
            # Export stats
            post(self.client, json=self.buffer, allow_redirects=True)
            # Reset buffer
            self.buffer = {}

        # Add current stat to the buffer
        self.buffer[name] = dict(zip(columns, points))
1111641
def list
      # TODO: remove dependency on Guard in this whole file
      # collect metadata
      data = PluginUtil.plugin_names.sort.inject({}) do |hash, name|
        hash[name.capitalize] = Guard.state.session.plugins.all(name).any?
        hash
      end

      # presentation
      header = [:Plugin, :Guardfile]
      final_rows = []
      data.each do |name, used|
        final_rows << { Plugin: name, Guardfile: used ? "✔" : "✘" }
      end

      # render
      Formatador.display_compact_table(final_rows, header)
    end
6619
def init_stats_history(self):
        """"""
        if self.history_enable():
            init_list = [a['name'] for a in self.get_items_history_list()]
            logger.debug("Stats history activated for plugin {} (items: {})".format(self.plugin_name, init_list))
        return GlancesHistory()