grr/server/grr_response_server/databases/mysql_flows.py
def ReadAllFlowRequestsAndResponses(self, client_id, flow_id, cursor=None):
    """Reads all requests and responses for a given flow from the database."""
    query = ("SELECT request, needs_processing, responses_expected, timestamp "
             "FROM flow_requests WHERE client_id=%s AND flow_id=%s")

    args = [
        mysql_utils.ClientIDToInt(client_id),
        mysql_utils.FlowIDToInt(flow_id)
    ]
    cursor.execute(query, args)

    requests = []
    for req, needs_processing, resp_expected, ts in cursor.fetchall():
      request = rdf_flow_objects.FlowRequest.FromSerializedString(req)
      request.needs_processing = needs_processing
      request.nr_responses_expected = resp_expected
      request.timestamp = mysql_utils.MysqlToRDFDatetime(ts)
      requests.append(request)

    query = ("SELECT response, status, iterator, timestamp "
             "FROM flow_responses WHERE client_id=%s AND flow_id=%s")
    cursor.execute(query, args)

    responses = {}
    for res, status, iterator, ts in cursor.fetchall():
      if status:
        response = rdf_flow_objects.FlowStatus.FromSerializedString(status)
      elif iterator:
        response = rdf_flow_objects.FlowIterator.FromSerializedString(iterator)
      else:
        response = rdf_flow_objects.FlowResponse.FromSerializedString(res)
      response.timestamp = mysql_utils.MysqlToRDFDatetime(ts)
      responses.setdefault(response.request_id,
                           {})[response.response_id] = response

    ret = []
    for req in sorted(requests, key=lambda r: r.request_id):
      ret.append((req, responses.get(req.request_id, {})))
    return ret
Reads all requests and responses for a given flow from the database.
Reads all requests and responses for a given flow from the database.
Reads all requests and responses for a given flow from the database .
def ReadAllFlowRequestsAndResponses(self, client_id, flow_id, cursor=None):
    query = ("SELECT request, needs_processing, responses_expected, timestamp "
             "FROM flow_requests WHERE client_id=%s AND flow_id=%s")
    args = [
        mysql_utils.ClientIDToInt(client_id),
        mysql_utils.FlowIDToInt(flow_id)
    ]
    cursor.execute(query, args)
    requests = []
    for req, needs_processing, resp_expected, ts in cursor.fetchall():
      request = rdf_flow_objects.FlowRequest.FromSerializedString(req)
      request.needs_processing = needs_processing
      request.nr_responses_expected = resp_expected
      request.timestamp = mysql_utils.MysqlToRDFDatetime(ts)
      requests.append(request)
    query = ("SELECT response, status, iterator, timestamp "
             "FROM flow_responses WHERE client_id=%s AND flow_id=%s")
    cursor.execute(query, args)
    responses = {}
    for res, status, iterator, ts in cursor.fetchall():
      if status:
        response = rdf_flow_objects.FlowStatus.FromSerializedString(status)
      elif iterator:
        response = rdf_flow_objects.FlowIterator.FromSerializedString(iterator)
      else:
        response = rdf_flow_objects.FlowResponse.FromSerializedString(res)
      response.timestamp = mysql_utils.MysqlToRDFDatetime(ts)
      responses.setdefault(response.request_id,
                           {})[response.response_id] = response
    ret = []
    for req in sorted(requests, key=lambda r: r.request_id):
      ret.append((req, responses.get(req.request_id, {})))
    return ret
def ReadAllFlowRequestsAndResponses ( self , client_id , flow_id , cursor = None ) : query = ( "SELECT request, needs_processing, responses_expected, timestamp " "FROM flow_requests WHERE client_id=%s AND flow_id=%s" ) args = [ mysql_utils . ClientIDToInt ( client_id ) , mysql_utils . FlowIDToInt ( flow_id ) ] cursor . execute ( query , args ) requests = [ ] for req , needs_processing , resp_expected , ts in cursor . fetchall ( ) : request = rdf_flow_objects . FlowRequest . FromSerializedString ( req ) request . needs_processing = needs_processing request . nr_responses_expected = resp_expected request . timestamp = mysql_utils . MysqlToRDFDatetime ( ts ) requests . append ( request ) query = ( "SELECT response, status, iterator, timestamp " "FROM flow_responses WHERE client_id=%s AND flow_id=%s" ) cursor . execute ( query , args ) responses = { } for res , status , iterator , ts in cursor . fetchall ( ) : if status : response = rdf_flow_objects . FlowStatus . FromSerializedString ( status ) elif iterator : response = rdf_flow_objects . FlowIterator . FromSerializedString ( iterator ) else : response = rdf_flow_objects . FlowResponse . FromSerializedString ( res ) response . timestamp = mysql_utils . MysqlToRDFDatetime ( ts ) responses . setdefault ( response . request_id , { } ) [ response . response_id ] = response ret = [ ] for req in sorted ( requests , key = lambda r : r . request_id ) : ret . append ( ( req , responses . get ( req . request_id , { } ) ) ) return ret
Reads all requests and responses for a given flow from the database.
Reads all requests and responses for a given flow from the database .
"""Reads all requests and responses for a given flow from the database."""
self
client_id
flow_id
cursor