grr/server/grr_response_server/databases/mysql_clients.py
def AddClientLabels(self, client_id, owner, labels, cursor=None):
    """Attaches a list of user labels to a client."""
    cid = mysql_utils.ClientIDToInt(client_id)
    labels = set(labels)
    args = [(cid, mysql_utils.Hash(owner), owner, label) for label in labels]
    args = list(itertools.chain.from_iterable(args))  # Flatten.

    query = """
          INSERT IGNORE INTO client_labels
              (client_id, owner_username_hash, owner_username, label)
          VALUES {}
          """.format(", ".join(["(%s, %s, %s, %s)"] * len(labels)))
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(client_id, cause=e)
Attaches a list of user labels to a client.
Attaches a list of user labels to a client.
Attaches a list of user labels to a client .
def AddClientLabels(self, client_id, owner, labels, cursor=None):
    cid = mysql_utils.ClientIDToInt(client_id)
    labels = set(labels)
    args = [(cid, mysql_utils.Hash(owner), owner, label) for label in labels]
    args = list(itertools.chain.from_iterable(args))  
    query = """
          INSERT IGNORE INTO client_labels
              (client_id, owner_username_hash, owner_username, label)
          VALUES {}
          """.format(", ".join(["(%s, %s, %s, %s)"] * len(labels)))
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(client_id, cause=e)
def AddClientLabels ( self , client_id , owner , labels , cursor = None ) : cid = mysql_utils . ClientIDToInt ( client_id ) labels = set ( labels ) args = [ ( cid , mysql_utils . Hash ( owner ) , owner , label ) for label in labels ] args = list ( itertools . chain . from_iterable ( args ) ) query = """
          INSERT IGNORE INTO client_labels
              (client_id, owner_username_hash, owner_username, label)
          VALUES {}
          """ . format ( ", " . join ( [ "(%s, %s, %s, %s)" ] * len ( labels ) ) ) try : cursor . execute ( query , args ) except MySQLdb . IntegrityError as e : raise db . UnknownClientError ( client_id , cause = e )
Attaches a list of user labels to a client.
Attaches a list of user labels to a client .
"""Attaches a list of user labels to a client.""" # Flatten.
self
client_id
owner
labels
cursor