Retrieve values for graphs.
334069
def retrieveVals(self):
        """"""
        if self.hasGraph('tomcat_memory'):
            stats = self._tomcatInfo.getMemoryStats()
            self.setGraphVal('tomcat_memory', 'used', 
                             stats['total'] - stats['free'])
            self.setGraphVal('tomcat_memory', 'free', stats['free'])
            self.setGraphVal('tomcat_memory', 'max', stats['max'])
        for (port, stats) in self._tomcatInfo.getConnectorStats().iteritems():
            thrstats = stats['threadInfo']
            reqstats = stats['requestInfo']
            if self.portIncluded(port):
                name = "tomcat_threads_%d" % port
                if self.hasGraph(name):
                    self.setGraphVal(name, 'busy', 
                                     thrstats['currentThreadsBusy'])
                    self.setGraphVal(name, 'idle', 
                                     thrstats['currentThreadCount'] 
                                     - thrstats['currentThreadsBusy'])
                    self.setGraphVal(name, 'max', thrstats['maxThreads'])
                name = "tomcat_access_%d" % port
                if self.hasGraph(name):
                    self.setGraphVal(name, 'reqs', reqstats['requestCount'])
                name = "tomcat_error_%d" % port
                if self.hasGraph(name):
                    self.setGraphVal(name, 'errors', reqstats['errorCount'])
                name = "tomcat_traffic_%d" % port
                if self.hasGraph(name):
                    self.setGraphVal(name, 'rx', reqstats['bytesReceived'])
                    self.setGraphVal(name, 'tx', reqstats['bytesSent'])
1301218
def get_data(self):
        """"""
        return self.x, self.y, self.w, self.h
1048746
def _values(self):
        """"""
        return [
            val[1] for serie in self.series for val in
            (serie.interpolated if self.interpolate else serie.points)
            if val[1] is not None and (not self.logarithmic or val[1] > 0)
        ]
956527
def graph(self, name, *args, **kwargs):
        
        return Graph(self, name, *args, **kwargs)
1161552
def values(self, limit=None, page=None):
        
        return self.get(limit=limit, page=page).values()
1032150
def get_root_graph(self,root):
      """"""
      children = self.get_children(root)
      g = Graph()
      nodes = [root]+children
      for node in nodes: g.add_node(node)
      node_ids = [x.id for x in nodes]
      edges = [x for x in self._edges.values() if x.node1.id in node_ids and x.node2.id in node_ids]
      for e in edges: g.add_edge(e)
      return g
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
565149
def get_graphs(self, run_key, debug=False):
    
    graph_dict = (self._run_key_to_debug_graphs if debug else
                  self._run_key_to_original_graphs)
    graph_wrappers = graph_dict.get(run_key, {})
    graph_defs = dict()
    for device_name, wrapper in graph_wrappers.items():
      graph_defs[device_name] = wrapper.graph_def
    return graph_defs
1155422
def GetReportData(self, get_report_args, token):
    """"""
    report = rdf_report_plugins.ApiReportData(
        representation_type=rdf_report_plugins.ApiReportData.RepresentationType
        .PIE_CHART)

    graph_series = client_report_utils.FetchMostRecentGraphSeries(
        get_report_args.client_label,
        rdf_stats.ClientGraphSeries.ReportType.OS_TYPE,
        token=token)
    if graph_series is not None:
      for graph in graph_series.graphs:
        # Find the correct graph and merge the OS categories together
        if "%s day" % self.__class__.ACTIVE_DAYS in graph.title:
          for sample in graph:
            report.pie_chart.data.Append(
                rdf_report_plugins.ApiReportDataPoint1D(
                    label=sample.label, x=sample.y_value))
          break

    report.pie_chart.data = sorted(
        report.pie_chart.data, key=lambda point: point.label)

    return report
750972
def _values(self):
        """"""
        if self.interpolate:
            return [
                val[0] for serie in self.series for val in serie.interpolated
            ]
        else:
            return super(Line, self)._values
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
586544
def itervalues(d, **kw):
    """"""
    if not PY2:
        return iter(d.values(**kw))
    return d.itervalues(**kw)
714452
def graphdata(data):
    """"""
    data = jh.get_ratings(data)
    num = 1
    rating_final = []
    episode_final = []
    for k,v in data.iteritems():
        rating=[]
        epinum=[]
        for r in v:
            if r != None:
                rating.append(float(r))
                epinum.append(num)
                num+=1
        rating_final.append(rating)
        episode_final.append(epinum)
    return rating_final,episode_final
563754
def values(self):
        
        if ver == (2, 7):
            return self.viewvalues()
        elif ver == (2, 6):
            return self.itervalues()
        elif ver >= (3, 0):
            return self.values()
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']])
173297
def retrieveVals(self):
        """"""
        for iface in self._ifaceList:
            if self._reqIfaceList is None or iface in self._reqIfaceList:
                if (self.graphEnabled('wanpipe_traffic') 
                    or self.graphEnabled('wanpipe_errors')):
                    stats = self._ifaceStats.get(iface)
                    if stats:
                        graph_name = 'wanpipe_traffic_%s' % iface
                        if self.hasGraph(graph_name):
                            for field in ('rxpackets', 'txpackets'):
                                self.setGraphVal(graph_name, field, 
                                                 stats.get(field))
                        graph_name = 'wanpipe_errors_%s' % iface
                        if self.hasGraph(graph_name):
                            for field in ('rxerrs', 'txerrs', 'rxframe', 'txcarrier',
                                'rxdrop', 'txdrop', 'rxfifo', 'txfifo'):
                                self.setGraphVal(graph_name, field, 
                                                 stats.get(field))
                if (self.graphEnabled('wanpipe_pri_errors') 
                    or self.graphEnabled('wanpipe_rxlevel')):
                    try:
                        stats = self._wanpipeInfo.getPRIstats(iface)
                    except:
                        stats = None
                    if stats:
                        graph_name = 'wanpipe_pri_errors_%s' % iface
                        if self.hasGraph(graph_name):
                            for field in ('linecodeviolation', 
                                          'farendblockerrors',
                                          'crc4errors', 'faserrors'):
                                self.setGraphVal(graph_name, field, 
                                                 stats.get(field))
                        if self.hasGraph('wanpipe_rxlevel'):
                            self.setGraphVal('wanpipe_pri_rxlevel', 
                                             iface, stats.get('rxlevel'))
818990
def __get_values(self):
        
        array = self._get_target().getDataArray()
        return tuple(itertools.chain.from_iterable(array))