Retrieve values for graphs.
507955
def retrieveVals(self):
        """"""
        apacheInfo = ApacheInfo(self._host, self._port,
                                self._user, self._password, 
                                self._statuspath, self._ssl)
        stats = apacheInfo.getServerStats()
        if self.hasGraph('apache_access'):
            self.setGraphVal('apache_access', 'reqs', stats['Total Accesses'])
        if self.hasGraph('apache_bytes'):
            self.setGraphVal('apache_bytes', 'bytes', 
                             stats['Total kBytes'] * 1000)
        if self.hasGraph('apache_workers'):
            self.setGraphVal('apache_workers', 'busy', stats['BusyWorkers'])
            self.setGraphVal('apache_workers', 'idle', stats['IdleWorkers'])
            self.setGraphVal('apache_workers', 'max', stats['MaxWorkers'])
775730
def get_subgraphs_by_citation(graph):
    
    rv = defaultdict(graph.fresh_copy)

    for u, v, key, data in graph.edges(keys=True, data=True):
        if CITATION not in data:
            continue
        dk = data[CITATION][CITATION_TYPE], data[CITATION][CITATION_REFERENCE]

        rv[dk].add_edge(u, v, key=key, **data)

    cleanup(graph, rv)

    return dict(rv)
64695
def values(self, **kwargs):
        """"""
        result = yield self.get(**kwargs)

        if not result['rows']:
            raise Return([])

        raise Return([x['value'] for x in result['rows']])
393841
def get_unused_list_annotation_values(graph) -> Mapping[str, Set[str]]:
    
    result = {}
    for annotation, values in graph.annotation_list.items():
        used_values = get_annotation_values(graph, annotation)
        if len(used_values) == len(values):  # all values have been used
            continue
        result[annotation] = set(values) - used_values
    return result
694991
def retrieveVals(self):
        """"""
        name = 'diskspace'
        if self.hasGraph(name):
            for fspath in self._fslist:
                if self._statsSpace.has_key(fspath):
                    self.setGraphVal(name, fspath, 
                                     self._statsSpace[fspath]['inuse_pcent'])
        name = 'diskinode'
        if self.hasGraph(name):
            for fspath in self._fslist:
                if self._statsInode.has_key(fspath):
                    self.setGraphVal(name, fspath, 
                                     self._statsInode[fspath]['inuse_pcent'])
453904
def get_subgraphs(graph=None):
    
    graph = graph or DEPENDENCIES
    keys = set(graph)
    frontier = set()
    seen = set()
    while keys:
        frontier.add(keys.pop())
        while frontier:
            component = frontier.pop()
            seen.add(component)
            frontier |= set([d for d in get_dependencies(component) if d in graph])
            frontier |= set([d for d in get_dependents(component) if d in graph])
            frontier -= seen
        yield dict((s, get_dependencies(s)) for s in seen)
        keys -= seen
        seen.clear()
689935
def __get_values(self):
        """"""
        values = []

        if self.__remote:
            description = self.__client.describe(self.__point)
            if description is not None:
                if description['type'] != 'Point':
                    raise IOTUnknown('%s is not a Point' % self.__point)
                values = description['meta']['values']
        else:
            limit = 100
            offset = 0
            while True:
                new = self.__point.list(limit=limit, offset=offset)
                values += new
                if len(new) < limit:
                    break
                offset += limit

            # Unlike for describe, value comments are keyed by language here, so unwrap to have same layout as for
            # describe call (default language only, if available).
            lang = self.__client.default_lang
            for value in values:
                value['comment'] = value['comment'].get(lang, None) if value['comment'] else None

        return values
32678
def get_graph(self, name):
        
        if name in self._graph_objs:
            return self._graph_objs[name]
        graphtypes = {
            'Graph': Graph,
            'DiGraph': DiGraph,
            'MultiGraph': MultiGraph,
            'MultiDiGraph': MultiDiGraph
        }
        type_s = self.query.graph_type(name)
        if type_s not in graphtypes:
            raise GraphNameError(
                "I don't know of a graph named {}".format(name)
            )
        g = graphtypes[type_s](self, name)
        self._graph_objs[name] = g
        return g
552724
def GetValues(self, fd):
    """"""
    result = None
    for result in fd.new_attributes.get(self, []):
      # We need to interpolate sub fields in this rdfvalue.
      if self.field_names:
        for x in self.GetSubFields(result, self.field_names):
          yield x

      else:
        yield result

    for result in fd.synced_attributes.get(self, []):
      result = result.ToRDFValue()

      # We need to interpolate sub fields in this rdfvalue.
      if result is not None:
        if self.field_names:
          for x in self.GetSubFields(result, self.field_names):
            yield x

        else:
          yield result

    if result is None:
      default = self.GetDefault(fd)
      if default is not None:
        yield default
1047315
def _FetchAllGraphSeriesFromTheLegacyDB(
    label,
    report_type,
    period = None,
    token = None
):
  """"""
  if period is None:
    time_range = aff4.ALL_TIMES
  else:
    range_end = rdfvalue.RDFDatetime.Now()
    time_range = (range_end - period, range_end)
  series_with_timestamps = {}
  try:
    stats_for_label = aff4.FACTORY.Open(
        GetAFF4ClientReportsURN().Add(label),
        aff4_type=aff4_stats.ClientFleetStats,
        mode="r",
        age=time_range,
        token=token)
  except aff4.InstantiationError:
    # Nothing to return for the given label and report-type.
    return series_with_timestamps
  aff4_attr = _GetAFF4AttributeForReportType(report_type)
  if aff4_attr.attribute_type == rdf_stats.GraphSeries:
    for graphs in stats_for_label.GetValuesForAttribute(aff4_attr):
      graph_series = rdf_stats.ClientGraphSeries(report_type=report_type)
      for graph in graphs:
        graph_series.graphs.Append(graph)
      series_with_timestamps[graphs.age] = graph_series
  elif aff4_attr.attribute_type == rdf_stats.Graph:
    for graph in stats_for_label.GetValuesForAttribute(aff4_attr):
      graph_series = rdf_stats.ClientGraphSeries(report_type=report_type)
      graph_series.graphs.Append(graph)
      series_with_timestamps[graph.age] = graph_series
  else:
    raise AFF4AttributeTypeError(aff4_attr.attribute_type)
  return series_with_timestamps
831327
def load_graphs():
    ''''''
    mestate.graphs = []
    gfiles = ['mavgraphs.xml']
    if 'HOME' in os.environ:
        for dirname, dirnames, filenames in os.walk(os.path.join(os.environ['HOME'], ".mavproxy")):
            for filename in filenames:
                
                if filename.lower().endswith('.xml'):
                    gfiles.append(os.path.join(dirname, filename))
    for file in gfiles:
        if not os.path.exists(file):
            continue
        graphs = load_graph_xml(open(file).read(), file)
        if graphs:
            mestate.graphs.extend(graphs)
            mestate.console.writeln("Loaded %s" % file)
    # also load the built in graphs
    dlist = pkg_resources.resource_listdir("MAVProxy", "tools/graphs")
    for f in dlist:
        raw = pkg_resources.resource_stream("MAVProxy", "tools/graphs/%s" % f).read()
        graphs = load_graph_xml(raw, None)
        if graphs:
            mestate.graphs.extend(graphs)
            mestate.console.writeln("Loaded %s" % f)
    mestate.graphs = sorted(mestate.graphs, key=lambda g: g.name)
777569
def _get_annotation_entries_from_data(self, graph: BELGraph, data: EdgeData) -> Optional[List[NamespaceEntry]]:
        """"""
        annotations_dict = data.get(ANNOTATIONS)
        if annotations_dict is not None:
            return [
                entry
                for url, names in self._iter_from_annotations_dict(graph, annotations_dict=annotations_dict)
                for entry in self.get_annotation_entries_by_names(url, names)
            ]
55197
def iter_annotation_values(graph, annotation: str) -> Iterable[str]:
    
    return (
        value
        for _, _, data in graph.edges(data=True)
        if edge_has_annotation(data, annotation)
        for value in data[ANNOTATIONS][annotation]
    )
1080544
def calculateValues(self):
        
        chart = self.chart()
        if not chart:
            return super(XDatasetAxis, self).calculateValues()
        else:
            values = []
            for dataset in chart.datasets():
                values.append(dataset.name())
            values.sort()
            return values
711651
def reloadGraphs(self) :
        ""
        r = self.connection.session.get(self.graphsURL)
        data = r.json()
        if r.status_code == 200 :
            self.graphs = {}
            for graphData in data["graphs"] :
                try :
                    self.graphs[graphData["_key"]] = GR.getGraphClass(graphData["_key"])(self, graphData)
                except KeyError :
                    self.graphs[graphData["_key"]] = Graph(self, graphData)
        else :
            raise UpdateError(data["errorMessage"], data)
115060
def get_graph_metadata(self, graph):
        
        _params = set()
        for tensor_vals in graph.initializer:
            _params.add(tensor_vals.name)

        input_data = []
        for graph_input in graph.input:
            if graph_input.name not in _params:
                shape = [val.dim_value for val in graph_input.type.tensor_type.shape.dim]
                input_data.append((graph_input.name, tuple(shape)))

        output_data = []
        for graph_out in graph.output:
            shape = [val.dim_value for val in graph_out.type.tensor_type.shape.dim]
            output_data.append((graph_out.name, tuple(shape)))
        metadata = {'input_tensor_data' : input_data,
                    'output_tensor_data' : output_data
                   }
        return metadata
574321
def values(self, axis=None):
        
        if axis is None:
            return self._plot
        else:
            return [value.get(axis) for value in self._plot]