grr/server/grr_response_server/databases/mysql_flows.py
def ReturnProcessedFlow(self, flow_obj, cursor=None):
    """Returns a flow that the worker was processing to the database."""
    query = ("SELECT needs_processing FROM flow_requests "
             "WHERE client_id=%s AND flow_id=%s AND request_id=%s")
    cursor.execute(query, [
        mysql_utils.ClientIDToInt(flow_obj.client_id),
        mysql_utils.FlowIDToInt(flow_obj.flow_id),
        flow_obj.next_request_to_process
    ])
    for row in cursor.fetchall():
      needs_processing = row[0]
      if needs_processing:
        return False

    update_query = ("UPDATE flows SET flow=%s, processing_on=%s, "
                    "processing_since=%s, processing_deadline=%s, "
                    "next_request_to_process=%s, last_update=%s "
                    "WHERE client_id=%s AND flow_id=%s")
    clone = flow_obj.Copy()
    clone.processing_on = None
    clone.processing_since = None
    clone.processing_deadline = None
    now = rdfvalue.RDFDatetime.Now()
    now_str = mysql_utils.RDFDatetimeToMysqlString(now)
    args = [
        clone.SerializeToString(), None, None, None,
        flow_obj.next_request_to_process, now_str,
        mysql_utils.ClientIDToInt(flow_obj.client_id),
        mysql_utils.FlowIDToInt(flow_obj.flow_id)
    ]
    cursor.execute(update_query, args)

    # This needs to happen after we are sure that the write has succeeded.
    flow_obj.processing_on = None
    flow_obj.processing_since = None
    flow_obj.processing_deadline = None

    return True
Returns a flow that the worker was processing to the database.
Returns a flow that the worker was processing to the database.
Returns a flow that the worker was processing to the database .
def ReturnProcessedFlow(self, flow_obj, cursor=None):
    query = ("SELECT needs_processing FROM flow_requests "
             "WHERE client_id=%s AND flow_id=%s AND request_id=%s")
    cursor.execute(query, [
        mysql_utils.ClientIDToInt(flow_obj.client_id),
        mysql_utils.FlowIDToInt(flow_obj.flow_id),
        flow_obj.next_request_to_process
    ])
    for row in cursor.fetchall():
      needs_processing = row[0]
      if needs_processing:
        return False
    update_query = ("UPDATE flows SET flow=%s, processing_on=%s, "
                    "processing_since=%s, processing_deadline=%s, "
                    "next_request_to_process=%s, last_update=%s "
                    "WHERE client_id=%s AND flow_id=%s")
    clone = flow_obj.Copy()
    clone.processing_on = None
    clone.processing_since = None
    clone.processing_deadline = None
    now = rdfvalue.RDFDatetime.Now()
    now_str = mysql_utils.RDFDatetimeToMysqlString(now)
    args = [
        clone.SerializeToString(), None, None, None,
        flow_obj.next_request_to_process, now_str,
        mysql_utils.ClientIDToInt(flow_obj.client_id),
        mysql_utils.FlowIDToInt(flow_obj.flow_id)
    ]
    cursor.execute(update_query, args)
    flow_obj.processing_on = None
    flow_obj.processing_since = None
    flow_obj.processing_deadline = None
    return True
def ReturnProcessedFlow ( self , flow_obj , cursor = None ) : query = ( "SELECT needs_processing FROM flow_requests " "WHERE client_id=%s AND flow_id=%s AND request_id=%s" ) cursor . execute ( query , [ mysql_utils . ClientIDToInt ( flow_obj . client_id ) , mysql_utils . FlowIDToInt ( flow_obj . flow_id ) , flow_obj . next_request_to_process ] ) for row in cursor . fetchall ( ) : needs_processing = row [ 0 ] if needs_processing : return False update_query = ( "UPDATE flows SET flow=%s, processing_on=%s, " "processing_since=%s, processing_deadline=%s, " "next_request_to_process=%s, last_update=%s " "WHERE client_id=%s AND flow_id=%s" ) clone = flow_obj . Copy ( ) clone . processing_on = None clone . processing_since = None clone . processing_deadline = None now = rdfvalue . RDFDatetime . Now ( ) now_str = mysql_utils . RDFDatetimeToMysqlString ( now ) args = [ clone . SerializeToString ( ) , None , None , None , flow_obj . next_request_to_process , now_str , mysql_utils . ClientIDToInt ( flow_obj . client_id ) , mysql_utils . FlowIDToInt ( flow_obj . flow_id ) ] cursor . execute ( update_query , args ) flow_obj . processing_on = None flow_obj . processing_since = None flow_obj . processing_deadline = None return True
Returns a flow that the worker was processing to the database.
Returns a flow that the worker was processing to the database .
"""Returns a flow that the worker was processing to the database.""" # This needs to happen after we are sure that the write has succeeded.
self
flow_obj
cursor