grr/server/grr_response_server/flow_base.py
def RunStateMethod(self, method_name, request=None, responses=None):
    """Completes the request by calling the state method.

    Args:
      method_name: The name of the state method to call.
      request: A RequestState protobuf.
      responses: A list of GrrMessages responding to the request.
    """
    if self.rdf_flow.pending_termination:
      self.Error(error_message=self.rdf_flow.pending_termination.reason)
      return

    client_id = self.rdf_flow.client_id

    deadline = self.rdf_flow.processing_deadline
    if deadline and rdfvalue.RDFDatetime.Now() > deadline:
      raise flow.FlowError("Processing time for flow %s on %s expired." %
                           (self.rdf_flow.flow_id, self.rdf_flow.client_id))

    self.rdf_flow.current_state = method_name
    if request and responses:
      logging.debug("Running %s for flow %s on %s, %d responses.", method_name,
                    self.rdf_flow.flow_id, client_id, len(responses))
    else:
      logging.debug("Running %s for flow %s on %s", method_name,
                    self.rdf_flow.flow_id, client_id)

    try:
      try:
        method = getattr(self, method_name)
      except AttributeError:
        raise ValueError("Flow %s has no state method %s" %
                         (self.__class__.__name__, method_name))

      # Prepare a responses object for the state method to use:
      responses = flow_responses.Responses.FromResponses(
          request=request, responses=responses)

      if responses.status is not None:
        self.SaveResourceUsage(responses.status)

      stats_collector_instance.Get().IncrementCounter("grr_worker_states_run")

      if method_name == "Start":
        stats_collector_instance.Get().IncrementCounter(
            "flow_starts", fields=[self.rdf_flow.flow_class_name])
        method()
      else:
        method(responses)

      if self.replies_to_process:
        if self.rdf_flow.parent_hunt_id and not self.rdf_flow.parent_flow_id:
          self._ProcessRepliesWithHuntOutputPlugins(self.replies_to_process)
        else:
          self._ProcessRepliesWithFlowOutputPlugins(self.replies_to_process)
        self.replies_to_process = []

    # We don't know here what exceptions can be thrown in the flow but we have
    # to continue. Thus, we catch everything.
    except Exception as e:  # pylint: disable=broad-except
      # This flow will terminate now
      stats_collector_instance.Get().IncrementCounter(
          "flow_errors", fields=[self.rdf_flow.flow_class_name])
      logging.exception("Flow %s on %s raised %s.", self.rdf_flow.flow_id,
                        client_id, utils.SmartUnicode(e))

      self.Error(
          error_message=utils.SmartUnicode(e), backtrace=traceback.format_exc())
Completes the request by calling the state method.

    Args:
      method_name: The name of the state method to call.
      request: A RequestState protobuf.
      responses: A list of GrrMessages responding to the request.
    
Completes the request by calling the state method.
Completes the request by calling the state method .
def RunStateMethod(self, method_name, request=None, responses=None):
    if self.rdf_flow.pending_termination:
      self.Error(error_message=self.rdf_flow.pending_termination.reason)
      return
    client_id = self.rdf_flow.client_id
    deadline = self.rdf_flow.processing_deadline
    if deadline and rdfvalue.RDFDatetime.Now() > deadline:
      raise flow.FlowError("Processing time for flow %s on %s expired." %
                           (self.rdf_flow.flow_id, self.rdf_flow.client_id))
    self.rdf_flow.current_state = method_name
    if request and responses:
      logging.debug("Running %s for flow %s on %s, %d responses.", method_name,
                    self.rdf_flow.flow_id, client_id, len(responses))
    else:
      logging.debug("Running %s for flow %s on %s", method_name,
                    self.rdf_flow.flow_id, client_id)
    try:
      try:
        method = getattr(self, method_name)
      except AttributeError:
        raise ValueError("Flow %s has no state method %s" %
                         (self.__class__.__name__, method_name))
      responses = flow_responses.Responses.FromResponses(
          request=request, responses=responses)
      if responses.status is not None:
        self.SaveResourceUsage(responses.status)
      stats_collector_instance.Get().IncrementCounter("grr_worker_states_run")
      if method_name == "Start":
        stats_collector_instance.Get().IncrementCounter(
            "flow_starts", fields=[self.rdf_flow.flow_class_name])
        method()
      else:
        method(responses)
      if self.replies_to_process:
        if self.rdf_flow.parent_hunt_id and not self.rdf_flow.parent_flow_id:
          self._ProcessRepliesWithHuntOutputPlugins(self.replies_to_process)
        else:
          self._ProcessRepliesWithFlowOutputPlugins(self.replies_to_process)
        self.replies_to_process = []
    except Exception as e:  
      stats_collector_instance.Get().IncrementCounter(
          "flow_errors", fields=[self.rdf_flow.flow_class_name])
      logging.exception("Flow %s on %s raised %s.", self.rdf_flow.flow_id,
                        client_id, utils.SmartUnicode(e))
      self.Error(
          error_message=utils.SmartUnicode(e), backtrace=traceback.format_exc())
def RunStateMethod ( self , method_name , request = None , responses = None ) : if self . rdf_flow . pending_termination : self . Error ( error_message = self . rdf_flow . pending_termination . reason ) return client_id = self . rdf_flow . client_id deadline = self . rdf_flow . processing_deadline if deadline and rdfvalue . RDFDatetime . Now ( ) > deadline : raise flow . FlowError ( "Processing time for flow %s on %s expired." % ( self . rdf_flow . flow_id , self . rdf_flow . client_id ) ) self . rdf_flow . current_state = method_name if request and responses : logging . debug ( "Running %s for flow %s on %s, %d responses." , method_name , self . rdf_flow . flow_id , client_id , len ( responses ) ) else : logging . debug ( "Running %s for flow %s on %s" , method_name , self . rdf_flow . flow_id , client_id ) try : try : method = getattr ( self , method_name ) except AttributeError : raise ValueError ( "Flow %s has no state method %s" % ( self . __class__ . __name__ , method_name ) ) responses = flow_responses . Responses . FromResponses ( request = request , responses = responses ) if responses . status is not None : self . SaveResourceUsage ( responses . status ) stats_collector_instance . Get ( ) . IncrementCounter ( "grr_worker_states_run" ) if method_name == "Start" : stats_collector_instance . Get ( ) . IncrementCounter ( "flow_starts" , fields = [ self . rdf_flow . flow_class_name ] ) method ( ) else : method ( responses ) if self . replies_to_process : if self . rdf_flow . parent_hunt_id and not self . rdf_flow . parent_flow_id : self . _ProcessRepliesWithHuntOutputPlugins ( self . replies_to_process ) else : self . _ProcessRepliesWithFlowOutputPlugins ( self . replies_to_process ) self . replies_to_process = [ ] except Exception as e : stats_collector_instance . Get ( ) . IncrementCounter ( "flow_errors" , fields = [ self . rdf_flow . flow_class_name ] ) logging . exception ( "Flow %s on %s raised %s." , self . rdf_flow . flow_id , client_id , utils . SmartUnicode ( e ) ) self . Error ( error_message = utils . SmartUnicode ( e ) , backtrace = traceback . format_exc ( ) )
Completes the request by calling the state method.
Completes the request by calling the state method .
"""Completes the request by calling the state method.

    Args:
      method_name: The name of the state method to call.
      request: A RequestState protobuf.
      responses: A list of GrrMessages responding to the request.
    """ # Prepare a responses object for the state method to use: # We don't know here what exceptions can be thrown in the flow but we have # to continue. Thus, we catch everything. # pylint: disable=broad-except # This flow will terminate now
self
method_name
The name of the state method to call.
The name of the state method to call .
request
A RequestState protobuf.
A RequestState protobuf .
responses
A list of GrrMessages responding to the request.
A list of GrrMessages responding to the request .