grr/server/grr_response_server/databases/mysql_clients.py
def ListClientsForKeywords(self, keywords, start_time=None, cursor=None):
    """Lists the clients associated with keywords."""
    keywords = set(keywords)
    hash_to_kw = {mysql_utils.Hash(kw): kw for kw in keywords}
    result = {kw: [] for kw in keywords}

    query = """
      SELECT keyword_hash, client_id
      FROM client_keywords
      WHERE keyword_hash IN ({})
    """.format(", ".join(["%s"] * len(result)))
    args = list(iterkeys(hash_to_kw))
    if start_time:
      query += " AND timestamp >= %s"
      args.append(mysql_utils.RDFDatetimeToMysqlString(start_time))
    cursor.execute(query, args)

    for kw_hash, cid in cursor.fetchall():
      result[hash_to_kw[kw_hash]].append(mysql_utils.IntToClientID(cid))
    return result
Lists the clients associated with keywords.
Lists the clients associated with keywords.
Lists the clients associated with keywords .
def ListClientsForKeywords(self, keywords, start_time=None, cursor=None):
    keywords = set(keywords)
    hash_to_kw = {mysql_utils.Hash(kw): kw for kw in keywords}
    result = {kw: [] for kw in keywords}
    query = """
      SELECT keyword_hash, client_id
      FROM client_keywords
      WHERE keyword_hash IN ({})
    """.format(", ".join(["%s"] * len(result)))
    args = list(iterkeys(hash_to_kw))
    if start_time:
      query += " AND timestamp >= %s"
      args.append(mysql_utils.RDFDatetimeToMysqlString(start_time))
    cursor.execute(query, args)
    for kw_hash, cid in cursor.fetchall():
      result[hash_to_kw[kw_hash]].append(mysql_utils.IntToClientID(cid))
    return result
def ListClientsForKeywords ( self , keywords , start_time = None , cursor = None ) : keywords = set ( keywords ) hash_to_kw = { mysql_utils . Hash ( kw ) : kw for kw in keywords } result = { kw : [ ] for kw in keywords } query = """
      SELECT keyword_hash, client_id
      FROM client_keywords
      WHERE keyword_hash IN ({})
    """ . format ( ", " . join ( [ "%s" ] * len ( result ) ) ) args = list ( iterkeys ( hash_to_kw ) ) if start_time : query += " AND timestamp >= %s" args . append ( mysql_utils . RDFDatetimeToMysqlString ( start_time ) ) cursor . execute ( query , args ) for kw_hash , cid in cursor . fetchall ( ) : result [ hash_to_kw [ kw_hash ] ] . append ( mysql_utils . IntToClientID ( cid ) ) return result
Lists the clients associated with keywords.
Lists the clients associated with keywords .
"""Lists the clients associated with keywords."""
self
keywords
start_time
cursor