'Store received ACPI tables from client in AFF4.'

@flow.StateHandler()
def TableReceived(self, responses):

    for response in responses:
        for log in response.logs:
            self.Log(log)
    table_signature = responses.request.request.payload.table_signature
    if (not responses.success):
        self.Log(('Error    retrieving    ACPI    table    with    signature    %s' % table_signature))
        return
    response = responses.First()
    if response.acpi_tables:
        self.Log(('Retrieved    ACPI    table(s)    with    signature    %s' % table_signature))
        with data_store.DB.GetMutationPool(token=self.token) as mutation_pool:
            collection_urn = self.client_id.Add(('devices/chipsec/acpi/tables/%s' % table_signature))
            for acpi_table_response in response.acpi_tables:
                hardware.ACPITableDataCollection.StaticAdd(collection_urn, self.token, acpi_table_response, mutation_pool=mutation_pool)
                self.SendReply(acpi_table_response)
