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

    client_id_int = mysql_utils.ClientIDToInt(client_id)

    query = ("SELECT startup_info, timestamp FROM client_startup_history "
             "WHERE 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 timestamp >= %s "
        args.append(mysql_utils.RDFDatetimeToMysqlString(time_from))

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

    query += "ORDER BY timestamp DESC "

    ret = []
    cursor.execute(query, args)

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