grr/server/grr_response_server/databases/mysql_flows.py
def WriteClientMessages(self, messages, cursor=None):
    """Writes messages that should go to the client to the db."""

    query = ("INSERT IGNORE INTO client_messages "
             "(client_id, message_id, timestamp, message) "
             "VALUES %s ON DUPLICATE KEY UPDATE "
             "timestamp=VALUES(timestamp), message=VALUES(message)")
    now = mysql_utils.RDFDatetimeToMysqlString(rdfvalue.RDFDatetime.Now())

    client_ids = set()

    value_templates = []
    args = []
    for m in messages:
      cid = db_utils.ClientIdFromGrrMessage(m)
      client_ids.add(cid)
      client_id_int = mysql_utils.ClientIDToInt(cid)
      args.extend([client_id_int, m.task_id, now, m.SerializeToString()])
      value_templates.append("(%s, %s, %s, %s)")

    query %= ",".join(value_templates)
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.AtLeastOneUnknownClientError(client_ids=client_ids, cause=e)
Writes messages that should go to the client to the db.
Writes messages that should go to the client to the db.
Writes messages that should go to the client to the db .
def WriteClientMessages(self, messages, cursor=None):
    query = ("INSERT IGNORE INTO client_messages "
             "(client_id, message_id, timestamp, message) "
             "VALUES %s ON DUPLICATE KEY UPDATE "
             "timestamp=VALUES(timestamp), message=VALUES(message)")
    now = mysql_utils.RDFDatetimeToMysqlString(rdfvalue.RDFDatetime.Now())
    client_ids = set()
    value_templates = []
    args = []
    for m in messages:
      cid = db_utils.ClientIdFromGrrMessage(m)
      client_ids.add(cid)
      client_id_int = mysql_utils.ClientIDToInt(cid)
      args.extend([client_id_int, m.task_id, now, m.SerializeToString()])
      value_templates.append("(%s, %s, %s, %s)")
    query %= ",".join(value_templates)
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.AtLeastOneUnknownClientError(client_ids=client_ids, cause=e)
def WriteClientMessages ( self , messages , cursor = None ) : query = ( "INSERT IGNORE INTO client_messages " "(client_id, message_id, timestamp, message) " "VALUES %s ON DUPLICATE KEY UPDATE " "timestamp=VALUES(timestamp), message=VALUES(message)" ) now = mysql_utils . RDFDatetimeToMysqlString ( rdfvalue . RDFDatetime . Now ( ) ) client_ids = set ( ) value_templates = [ ] args = [ ] for m in messages : cid = db_utils . ClientIdFromGrrMessage ( m ) client_ids . add ( cid ) client_id_int = mysql_utils . ClientIDToInt ( cid ) args . extend ( [ client_id_int , m . task_id , now , m . SerializeToString ( ) ] ) value_templates . append ( "(%s, %s, %s, %s)" ) query %= "," . join ( value_templates ) try : cursor . execute ( query , args ) except MySQLdb . IntegrityError as e : raise db . AtLeastOneUnknownClientError ( client_ids = client_ids , cause = e )
Writes messages that should go to the client to the db.
Writes messages that should go to the client to the db .
"""Writes messages that should go to the client to the db."""
self
messages
cursor