grr/server/grr_response_server/db.py
def _ValidateStatsStoreEntries(stats_entries):
  """Validates an Iterable of StatsStoreEntries."""
  for stats_entry in stats_entries:
    precondition.AssertType(stats_entry, stats_values.StatsStoreEntry)
    if not stats_entry.process_id:
      raise ValueError("StatsStoreEntry must have a process_id set.")
    if not stats_entry.metric_name:
      raise ValueError("StatsStoreEntry must have a metric_name set.")
    if not stats_entry.metric_value:
      raise ValueError("StatsStoreEntry must have a metric_value set.")
    if not stats_entry.timestamp:
      raise ValueError("StatsStoreEntry must have a timestamp set.")

    metric_metadata = stats_collector_instance.Get().GetMetricMetadata(
        stats_entry.metric_name)
    num_field_values = len(stats_entry.metric_value.fields_values)
    expected_num_field_values = len(metric_metadata.fields_defs)
    if num_field_values != expected_num_field_values:
      raise ValueError(
          "Value for metric %s had %d field values, yet the metric was "
          "defined to have %d fields." % (stats_entry.metric_name,
                                          num_field_values,
                                          expected_num_field_values))
Validates an Iterable of StatsStoreEntries.
Validates an Iterable of StatsStoreEntries.
Validates an Iterable of StatsStoreEntries .
def _ValidateStatsStoreEntries(stats_entries):
  for stats_entry in stats_entries:
    precondition.AssertType(stats_entry, stats_values.StatsStoreEntry)
    if not stats_entry.process_id:
      raise ValueError("StatsStoreEntry must have a process_id set.")
    if not stats_entry.metric_name:
      raise ValueError("StatsStoreEntry must have a metric_name set.")
    if not stats_entry.metric_value:
      raise ValueError("StatsStoreEntry must have a metric_value set.")
    if not stats_entry.timestamp:
      raise ValueError("StatsStoreEntry must have a timestamp set.")
    metric_metadata = stats_collector_instance.Get().GetMetricMetadata(
        stats_entry.metric_name)
    num_field_values = len(stats_entry.metric_value.fields_values)
    expected_num_field_values = len(metric_metadata.fields_defs)
    if num_field_values != expected_num_field_values:
      raise ValueError(
          "Value for metric %s had %d field values, yet the metric was "
          "defined to have %d fields." % (stats_entry.metric_name,
                                          num_field_values,
                                          expected_num_field_values))
def _ValidateStatsStoreEntries ( stats_entries ) : for stats_entry in stats_entries : precondition . AssertType ( stats_entry , stats_values . StatsStoreEntry ) if not stats_entry . process_id : raise ValueError ( "StatsStoreEntry must have a process_id set." ) if not stats_entry . metric_name : raise ValueError ( "StatsStoreEntry must have a metric_name set." ) if not stats_entry . metric_value : raise ValueError ( "StatsStoreEntry must have a metric_value set." ) if not stats_entry . timestamp : raise ValueError ( "StatsStoreEntry must have a timestamp set." ) metric_metadata = stats_collector_instance . Get ( ) . GetMetricMetadata ( stats_entry . metric_name ) num_field_values = len ( stats_entry . metric_value . fields_values ) expected_num_field_values = len ( metric_metadata . fields_defs ) if num_field_values != expected_num_field_values : raise ValueError ( "Value for metric %s had %d field values, yet the metric was " "defined to have %d fields." % ( stats_entry . metric_name , num_field_values , expected_num_field_values ) )
Validates an Iterable of StatsStoreEntries.
Validates an Iterable of StatsStoreEntries .
"""Validates an Iterable of StatsStoreEntries."""
stats_entries