grr/server/grr_response_server/db_compat.py
def WriteHuntResults(client_id, hunt_id, responses):
  """Writes hunt results from a given client as part of a given hunt."""

  if not hunt.IsLegacyHunt(hunt_id):
    data_store.REL_DB.WriteFlowResults(responses)

    def UpdateFn(hunt_obj):
      hunt_obj.num_results += len(responses)
      return hunt_obj

    hunt_obj = data_store.REL_DB.UpdateHuntObject(hunt_id, UpdateFn)
    hunt_obj = hunt.StopHuntIfAverageLimitsExceeded(hunt_obj)
    return

  hunt_id_urn = rdfvalue.RDFURN("hunts").Add(hunt_id)

  msgs = []
  for response in responses:
    if isinstance(response, rdf_flow_objects.FlowStatus):
      continue

    msgs.append(
        rdf_flows.GrrMessage(payload=response.payload, source=client_id))

  with data_store.DB.GetMutationPool() as pool:
    for msg in msgs:
      hunts_results.HuntResultCollection.StaticAdd(
          hunt_id_urn.Add("Results"), msg, mutation_pool=pool)

    for msg in msgs:
      multi_type_collection.MultiTypeCollection.StaticAdd(
          hunt_id_urn.Add("ResultsPerType"), msg, mutation_pool=pool)

  stats_collector_instance.Get().IncrementCounter(
      "hunt_results_added", delta=len(responses))
Writes hunt results from a given client as part of a given hunt.
Writes hunt results from a given client as part of a given hunt.
Writes hunt results from a given client as part of a given hunt .
def WriteHuntResults(client_id, hunt_id, responses):
  if not hunt.IsLegacyHunt(hunt_id):
    data_store.REL_DB.WriteFlowResults(responses)
    def UpdateFn(hunt_obj):
      hunt_obj.num_results += len(responses)
      return hunt_obj
    hunt_obj = data_store.REL_DB.UpdateHuntObject(hunt_id, UpdateFn)
    hunt_obj = hunt.StopHuntIfAverageLimitsExceeded(hunt_obj)
    return
  hunt_id_urn = rdfvalue.RDFURN("hunts").Add(hunt_id)
  msgs = []
  for response in responses:
    if isinstance(response, rdf_flow_objects.FlowStatus):
      continue
    msgs.append(
        rdf_flows.GrrMessage(payload=response.payload, source=client_id))
  with data_store.DB.GetMutationPool() as pool:
    for msg in msgs:
      hunts_results.HuntResultCollection.StaticAdd(
          hunt_id_urn.Add("Results"), msg, mutation_pool=pool)
    for msg in msgs:
      multi_type_collection.MultiTypeCollection.StaticAdd(
          hunt_id_urn.Add("ResultsPerType"), msg, mutation_pool=pool)
  stats_collector_instance.Get().IncrementCounter(
      "hunt_results_added", delta=len(responses))
def WriteHuntResults ( client_id , hunt_id , responses ) : if not hunt . IsLegacyHunt ( hunt_id ) : data_store . REL_DB . WriteFlowResults ( responses ) def UpdateFn ( hunt_obj ) : hunt_obj . num_results += len ( responses ) return hunt_obj hunt_obj = data_store . REL_DB . UpdateHuntObject ( hunt_id , UpdateFn ) hunt_obj = hunt . StopHuntIfAverageLimitsExceeded ( hunt_obj ) return hunt_id_urn = rdfvalue . RDFURN ( "hunts" ) . Add ( hunt_id ) msgs = [ ] for response in responses : if isinstance ( response , rdf_flow_objects . FlowStatus ) : continue msgs . append ( rdf_flows . GrrMessage ( payload = response . payload , source = client_id ) ) with data_store . DB . GetMutationPool ( ) as pool : for msg in msgs : hunts_results . HuntResultCollection . StaticAdd ( hunt_id_urn . Add ( "Results" ) , msg , mutation_pool = pool ) for msg in msgs : multi_type_collection . MultiTypeCollection . StaticAdd ( hunt_id_urn . Add ( "ResultsPerType" ) , msg , mutation_pool = pool ) stats_collector_instance . Get ( ) . IncrementCounter ( "hunt_results_added" , delta = len ( responses ) )
Writes hunt results from a given client as part of a given hunt.
Writes hunt results from a given client as part of a given hunt .
"""Writes hunt results from a given client as part of a given hunt."""
client_id
hunt_id
responses