grr/server/grr_response_server/databases/mysql_clients.py
def ReadClientSnapshotHistory(self, client_id, timerange=None, cursor=None):
    """Reads the full history for a particular client."""

    client_id_int = mysql_utils.ClientIDToInt(client_id)

    query = ("SELECT sn.client_snapshot, st.startup_info, sn.timestamp FROM "
             "client_snapshot_history AS sn, "
             "client_startup_history AS st WHERE "
             "sn.client_id = st.client_id AND "
             "sn.timestamp = st.timestamp AND "
             "sn.client_id=%s ")

    args = [client_id_int]
    if timerange:
      time_from, time_to = timerange  # pylint: disable=unpacking-non-sequence

      if time_from is not None:
        query += "AND sn.timestamp >= %s "
        args.append(mysql_utils.RDFDatetimeToMysqlString(time_from))

      if time_to is not None:
        query += "AND sn.timestamp <= %s "
        args.append(mysql_utils.RDFDatetimeToMysqlString(time_to))

    query += "ORDER BY sn.timestamp DESC"

    ret = []
    cursor.execute(query, args)
    for snapshot, startup_info, timestamp in cursor.fetchall():
      client = rdf_objects.ClientSnapshot.FromSerializedString(snapshot)
      client.startup_info = rdf_client.StartupInfo.FromSerializedString(
          startup_info)
      client.timestamp = mysql_utils.MysqlToRDFDatetime(timestamp)

      ret.append(client)
    return ret
Reads the full history for a particular client.
Reads the full history for a particular client.
Reads the full history for a particular client .
def ReadClientSnapshotHistory(self, client_id, timerange=None, cursor=None):
    client_id_int = mysql_utils.ClientIDToInt(client_id)
    query = ("SELECT sn.client_snapshot, st.startup_info, sn.timestamp FROM "
             "client_snapshot_history AS sn, "
             "client_startup_history AS st WHERE "
             "sn.client_id = st.client_id AND "
             "sn.timestamp = st.timestamp AND "
             "sn.client_id=%s ")
    args = [client_id_int]
    if timerange:
      time_from, time_to = timerange  
      if time_from is not None:
        query += "AND sn.timestamp >= %s "
        args.append(mysql_utils.RDFDatetimeToMysqlString(time_from))
      if time_to is not None:
        query += "AND sn.timestamp <= %s "
        args.append(mysql_utils.RDFDatetimeToMysqlString(time_to))
    query += "ORDER BY sn.timestamp DESC"
    ret = []
    cursor.execute(query, args)
    for snapshot, startup_info, timestamp in cursor.fetchall():
      client = rdf_objects.ClientSnapshot.FromSerializedString(snapshot)
      client.startup_info = rdf_client.StartupInfo.FromSerializedString(
          startup_info)
      client.timestamp = mysql_utils.MysqlToRDFDatetime(timestamp)
      ret.append(client)
    return ret
def ReadClientSnapshotHistory ( self , client_id , timerange = None , cursor = None ) : client_id_int = mysql_utils . ClientIDToInt ( client_id ) query = ( "SELECT sn.client_snapshot, st.startup_info, sn.timestamp FROM " "client_snapshot_history AS sn, " "client_startup_history AS st WHERE " "sn.client_id = st.client_id AND " "sn.timestamp = st.timestamp AND " "sn.client_id=%s " ) args = [ client_id_int ] if timerange : time_from , time_to = timerange if time_from is not None : query += "AND sn.timestamp >= %s " args . append ( mysql_utils . RDFDatetimeToMysqlString ( time_from ) ) if time_to is not None : query += "AND sn.timestamp <= %s " args . append ( mysql_utils . RDFDatetimeToMysqlString ( time_to ) ) query += "ORDER BY sn.timestamp DESC" ret = [ ] cursor . execute ( query , args ) for snapshot , startup_info , timestamp in cursor . fetchall ( ) : client = rdf_objects . ClientSnapshot . FromSerializedString ( snapshot ) client . startup_info = rdf_client . StartupInfo . FromSerializedString ( startup_info ) client . timestamp = mysql_utils . MysqlToRDFDatetime ( timestamp ) ret . append ( client ) return ret
Reads the full history for a particular client.
Reads the full history for a particular client .
"""Reads the full history for a particular client.""" # pylint: disable=unpacking-non-sequence
self
client_id
timerange
cursor