Writes messages that should go to the client to the db.
329836
def WriteClientActionRequests(self, requests, cursor=None):
    """"""

    query = ("INSERT IGNORE INTO client_action_requests "
             "(client_id, flow_id, request_id, timestamp, request) "
             "VALUES %s ON DUPLICATE KEY UPDATE "
             "timestamp=VALUES(timestamp), request=VALUES(request)")
    now = mysql_utils.RDFDatetimeToTimestamp(rdfvalue.RDFDatetime.Now())

    value_templates = []
    args = []
    for r in requests:
      args.extend([
          db_utils.ClientIDToInt(r.client_id),
          db_utils.FlowIDToInt(r.flow_id), r.request_id, now,
          r.SerializeToString()
      ])
      value_templates.append("(%s, %s, %s, FROM_UNIXTIME(%s), %s)")

    query %= ",".join(value_templates)
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      request_keys = [(r.client_id, r.flow_id, r.request_id) for r in requests]
      raise db.AtLeastOneUnknownRequestError(request_keys=request_keys, cause=e)
516872
public void sendBatch() {
        LrsStatement statement = null;
        List<LrsStatement> list = new ArrayList<LrsStatement>();

        while ((statement = statementQueue.poll()) != null) {
            list.add(statement);
        }

        if (!list.isEmpty()) {
            postStatementList(list);
        }
    }
1241285
def send_data(self, message):
        '''
            
        '''
        #logger.debug("TX:\n%s", json.dumps(message, indent=2))
        data = json.dumps(message).encode('utf-8') + b'\n'
        self.transport.write(data)
278268
public static <T> void writeListTo(XMLStreamWriter writer, List<T> messages, Schema<T> schema)
            throws IOException, XMLStreamException
    {
        writer.writeStartElement("list");

        if (messages.isEmpty())
        {
            writer.writeEndElement();
            return;
        }

        final String simpleName = schema.messageName();
        final XmlOutput output = new XmlOutput(writer, schema);
        for (T m : messages)
        {
            writer.writeStartElement(simpleName);
            schema.writeTo(output, m);
            writer.writeEndElement();
        }

        writer.writeEndElement();
    }
739076
public static <T> void writeListTo(LinkedBuffer buffer,
            List<T> messages, Schema<T> schema, boolean numeric)
    {
        if (buffer.start != buffer.offset)
        {
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");
        }

        if (messages.isEmpty())
        {
            return;
        }

        MsgpackXOutput output = new MsgpackXOutput(buffer, numeric, schema);

        try
        {

            for (T m : messages)
            {

                LinkedBuffer objectStarter = output.writeStartObject();
                schema.writeTo(output, m);

                if (output.isLastRepeated())
                {
                    output.writeEndArray();
                }

                output.writeEndObject(objectStarter);

            }

        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }
    }
210777
def write_message(self, data, binary=False):
        
        self.connection.write_message(data, binary)
1040748
function DbWriter(db,errorLogObject,successLogObject) {
	this.db = db;
	this.errorLogObject = errorLogObject;
	this.successLogObject = successLogObject;
}
1256796
public static <MSG extends Message> void writeStream(Iterable<MSG> messages, File toFile, boolean append) {
    OutputStream out = null;
    try {
      out = new BufferedOutputStream(new FileOutputStream(toFile, append));
      writeStream(messages, out);
    } catch (Exception e) {
      throw ContextException.of("Unable to write messages", e).addContext("file", toFile);
    } finally {
      IOUtils.closeQuietly(out);
    }
  }
976637
def message(self, data, kind="info"):
        """"""
        message = pd.io.json.dumps({'kind': kind, 'data': data})
        print("Sent {0} bytes.".format(len(message)))
        self.write_message(message)
766502
@GuardedBy("lock") protected void sendBundledMessages() {
        for(Map.Entry<Address,List<Message>> entry: msgs.entrySet()) {
            List<Message> list=entry.getValue();
            if(list.isEmpty())
                continue;

            output.position(0);
            if(list.size() == 1)
                sendSingleMessage(list.get(0));
            else {
                Address dst=entry.getKey();
                sendMessageList(dst, list.get(0).getSrc(), list);
                if(transport.statsEnabled())
                    transport.incrBatchesSent(1);
            }
        }
        clearMessages();
        count=0;
    }
611141
@SafeVarargs
    public final <T extends Client> void writeAndFlush(T... clients) {
        if (clients.length == 0) {
            throw new IllegalArgumentException("You must send this packet to at least one client!");
        }

        for (var client : clients) {
            writeAndFlush(client);
        }
    }
241224
public function export()
    {
        $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n";
        fwrite($this->getFp(), $text);
    }
454336
public function export()
    {
        $rows = [];
        foreach ($this->messages as $message) {
            list($text, $level, $category, $timestamp) = $message;
            if (!is_string($text)) {
                // exceptions may not be serializable if in the call stack somewhere is a Closure
                if ($text instanceof \Throwable || $text instanceof \Exception) {
                    $text = (string) $text;
                } else {
                    $text = VarDumper::export($text);
                }
            }
            $rows[] = [
                'level' => $level,
                'category' => $category,
                'log_time' => $timestamp,
                'prefix' => $this->getMessagePrefix($message),
                'message' => $text,
            ];
        }

        $this->db->getCollection($this->logCollection)->batchInsert($rows);
    }
794022
def writemessage(self, text):
        """"""
        log.debug('writing message %r', text)
        self.write(chr(10)+text+chr(10))
        self.write(self._current_prompt+''.join(self._current_line))
1000276
def WriteClientActionRequests(self, requests):
    """"""
    for r in requests:
      req_dict = self.flow_requests.get((r.client_id, r.flow_id), {})
      if r.request_id not in req_dict:
        request_keys = [(r.client_id, r.flow_id, r.request_id) for r in requests
                       ]
        raise db.AtLeastOneUnknownRequestError(request_keys)

    for r in requests:
      request_key = (r.client_id, r.flow_id, r.request_id)
      self.client_action_requests[request_key] = r
909220
def send(self, message, callback=None):
        """"""
        assert isinstance(message, velbus.Message)
        self._write_queue.put_nowait((message, callback))
916884
public final void writeAndFlush(Collection<? extends Client> clients) {
        if (clients.isEmpty()) {
            throw new IllegalArgumentException("You must send this packet to at least one client!");
        }

        clients.forEach(this::writeAndFlush);
    }