grr/server/grr_response_server/stats_store.py
def _ConvertStatsEntriesToDataQueryFormat(
    stats_entries
):
  """Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery.

  Args:
    stats_entries: An Iterable of StatsStoreEntries.

  Returns:
    A dict organized in the format expected by the StatsStoreDataQuery
    class (see the class's __init__() method for details).
  """
  results_dict = {}
  for stats_entry in sorted(stats_entries, key=lambda e: e.timestamp):
    results_for_process = results_dict.setdefault(stats_entry.process_id, {})
    metadata = stats_collector_instance.Get().GetMetricMetadata(
        stats_entry.metric_name)
    if metadata.fields_defs:
      field_values = [v.value for v in stats_entry.metric_value.fields_values]
      _ValidateFieldValues(field_values, metadata)
      innermost_dict = results_for_process.setdefault(stats_entry.metric_name,
                                                      {})
      for field_value in field_values[:-1]:
        innermost_dict = innermost_dict.setdefault(field_value, {})
      values_list = innermost_dict.setdefault(field_values[-1], [])
    else:
      values_list = results_for_process.setdefault(stats_entry.metric_name, [])
    micros_timestamp = stats_entry.timestamp.AsMicrosecondsSinceEpoch()
    values_list.append((stats_entry.metric_value.value, micros_timestamp))
  return results_dict
Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery.

  Args:
    stats_entries: An Iterable of StatsStoreEntries.

  Returns:
    A dict organized in the format expected by the StatsStoreDataQuery
    class (see the class's __init__() method for details).
  
Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery.
Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery .
def _ConvertStatsEntriesToDataQueryFormat(
    stats_entries
):
  results_dict = {}
  for stats_entry in sorted(stats_entries, key=lambda e: e.timestamp):
    results_for_process = results_dict.setdefault(stats_entry.process_id, {})
    metadata = stats_collector_instance.Get().GetMetricMetadata(
        stats_entry.metric_name)
    if metadata.fields_defs:
      field_values = [v.value for v in stats_entry.metric_value.fields_values]
      _ValidateFieldValues(field_values, metadata)
      innermost_dict = results_for_process.setdefault(stats_entry.metric_name,
                                                      {})
      for field_value in field_values[:-1]:
        innermost_dict = innermost_dict.setdefault(field_value, {})
      values_list = innermost_dict.setdefault(field_values[-1], [])
    else:
      values_list = results_for_process.setdefault(stats_entry.metric_name, [])
    micros_timestamp = stats_entry.timestamp.AsMicrosecondsSinceEpoch()
    values_list.append((stats_entry.metric_value.value, micros_timestamp))
  return results_dict
def _ConvertStatsEntriesToDataQueryFormat ( stats_entries ) : results_dict = { } for stats_entry in sorted ( stats_entries , key = lambda e : e . timestamp ) : results_for_process = results_dict . setdefault ( stats_entry . process_id , { } ) metadata = stats_collector_instance . Get ( ) . GetMetricMetadata ( stats_entry . metric_name ) if metadata . fields_defs : field_values = [ v . value for v in stats_entry . metric_value . fields_values ] _ValidateFieldValues ( field_values , metadata ) innermost_dict = results_for_process . setdefault ( stats_entry . metric_name , { } ) for field_value in field_values [ : - 1 ] : innermost_dict = innermost_dict . setdefault ( field_value , { } ) values_list = innermost_dict . setdefault ( field_values [ - 1 ] , [ ] ) else : values_list = results_for_process . setdefault ( stats_entry . metric_name , [ ] ) micros_timestamp = stats_entry . timestamp . AsMicrosecondsSinceEpoch ( ) values_list . append ( ( stats_entry . metric_value . value , micros_timestamp ) ) return results_dict
Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery.
Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery .
"""Converts StatsStoreEntries to a format expected by a StatsStoreDataQuery.

  Args:
    stats_entries: An Iterable of StatsStoreEntries.

  Returns:
    A dict organized in the format expected by the StatsStoreDataQuery
    class (see the class's __init__() method for details).
  """
A dict organized in the format expected by the StatsStoreDataQuery
class  method for details).
A dict organized in the format expected by the StatsStoreDataQuery class method for details ) .
stats_entries
An Iterable of StatsStoreEntries.
An Iterable of StatsStoreEntries .