grr/server/grr_response_server/databases/mysql_clients.py
def MultiReadClientSnapshot(self, client_ids, cursor=None):
    """Reads the latest client snapshots for a list of clients."""
    int_ids = [mysql_utils.ClientIDToInt(cid) for cid in client_ids]
    query = (
        "SELECT h.client_id, h.client_snapshot, h.timestamp, s.startup_info "
        "FROM clients as c, client_snapshot_history as h, "
        "client_startup_history as s "
        "WHERE h.client_id = c.client_id "
        "AND s.client_id = c.client_id "
        "AND h.timestamp = c.last_client_timestamp "
        "AND s.timestamp = c.last_startup_timestamp "
        "AND c.client_id IN ({})").format(", ".join(["%s"] * len(client_ids)))
    ret = {cid: None for cid in client_ids}
    cursor.execute(query, int_ids)
    while True:
      row = cursor.fetchone()
      if not row:
        break
      cid, snapshot, timestamp, startup_info = row
      client_obj = mysql_utils.StringToRDFProto(rdf_objects.ClientSnapshot,
                                                snapshot)
      client_obj.startup_info = mysql_utils.StringToRDFProto(
          rdf_client.StartupInfo, startup_info)
      client_obj.timestamp = mysql_utils.MysqlToRDFDatetime(timestamp)
      ret[mysql_utils.IntToClientID(cid)] = client_obj
    return ret
Reads the latest client snapshots for a list of clients.
Reads the latest client snapshots for a list of clients.
Reads the latest client snapshots for a list of clients .
def MultiReadClientSnapshot(self, client_ids, cursor=None):
    int_ids = [mysql_utils.ClientIDToInt(cid) for cid in client_ids]
    query = (
        "SELECT h.client_id, h.client_snapshot, h.timestamp, s.startup_info "
        "FROM clients as c, client_snapshot_history as h, "
        "client_startup_history as s "
        "WHERE h.client_id = c.client_id "
        "AND s.client_id = c.client_id "
        "AND h.timestamp = c.last_client_timestamp "
        "AND s.timestamp = c.last_startup_timestamp "
        "AND c.client_id IN ({})").format(", ".join(["%s"] * len(client_ids)))
    ret = {cid: None for cid in client_ids}
    cursor.execute(query, int_ids)
    while True:
      row = cursor.fetchone()
      if not row:
        break
      cid, snapshot, timestamp, startup_info = row
      client_obj = mysql_utils.StringToRDFProto(rdf_objects.ClientSnapshot,
                                                snapshot)
      client_obj.startup_info = mysql_utils.StringToRDFProto(
          rdf_client.StartupInfo, startup_info)
      client_obj.timestamp = mysql_utils.MysqlToRDFDatetime(timestamp)
      ret[mysql_utils.IntToClientID(cid)] = client_obj
    return ret
def MultiReadClientSnapshot ( self , client_ids , cursor = None ) : int_ids = [ mysql_utils . ClientIDToInt ( cid ) for cid in client_ids ] query = ( "SELECT h.client_id, h.client_snapshot, h.timestamp, s.startup_info " "FROM clients as c, client_snapshot_history as h, " "client_startup_history as s " "WHERE h.client_id = c.client_id " "AND s.client_id = c.client_id " "AND h.timestamp = c.last_client_timestamp " "AND s.timestamp = c.last_startup_timestamp " "AND c.client_id IN ({})" ) . format ( ", " . join ( [ "%s" ] * len ( client_ids ) ) ) ret = { cid : None for cid in client_ids } cursor . execute ( query , int_ids ) while True : row = cursor . fetchone ( ) if not row : break cid , snapshot , timestamp , startup_info = row client_obj = mysql_utils . StringToRDFProto ( rdf_objects . ClientSnapshot , snapshot ) client_obj . startup_info = mysql_utils . StringToRDFProto ( rdf_client . StartupInfo , startup_info ) client_obj . timestamp = mysql_utils . MysqlToRDFDatetime ( timestamp ) ret [ mysql_utils . IntToClientID ( cid ) ] = client_obj return ret
Reads the latest client snapshots for a list of clients.
Reads the latest client snapshots for a list of clients .
"""Reads the latest client snapshots for a list of clients."""
self
client_ids
cursor