Writes data to the device.

        :param data: data to write
        :type data: string

        :returns: number of bytes sent
        :raises: :py:class:`~alarmdecoder.util.CommError`
438849
def write(self, data):
        
        data_sent = None

        try:
            if isinstance(data, str):
                data = data.encode('utf-8')

            data_sent = self._device.send(data)

            if data_sent == 0:
                raise CommError('Error writing to device.')

            self.on_write(data=data)

        except (SSL.Error, socket.error) as err:
            raise CommError('Error writing to device.', err)

        return data_sent
951645
def write(self, data):
        
        if self.padded:
            # flush out any remaining bits first
            if len(self._bits) > 0:
                self._flush_bits_to_stream()
            self._stream.write(data)
        else:
            # nothing to do here
            if len(data) == 0:
                return

            bits = bytes_to_bits(data)
            self.write_bits(bits)
141480
def write(self, data, report_id=0):
        

        if not self._is_open:
            raise HIDException("HIDDevice not open")

        write_data = bytearray([report_id]) + bytearray(data)
        cdata = ffi.new("const unsigned char[]", bytes(write_data))
        num_written = hidapi.hid_write(self._device, cdata, len(write_data))
        if num_written < 0:
            raise HIDException("Failed to write to HID device: " + str(num_written))
        else:
            return num_written
1014867
def write(self, data):
        
        _complain_ifclosed(self.closed)
        if self.__encoding:
            self.f.write(data.encode(self.__encoding, self.__errors))
            return len(data)
        else:
            return self.f.write(data)
300435
def write_to_socket(self, frame_data):
        
        self._wr_lock.acquire()
        try:
            total_bytes_written = 0
            bytes_to_send = len(frame_data)
            while total_bytes_written < bytes_to_send:
                try:
                    if not self.socket:
                        raise socket.error('connection/socket error')
                    bytes_written = (
                        self.socket.send(frame_data[total_bytes_written:])
                    )
                    if bytes_written == 0:
                        raise socket.error('connection/socket error')
                    total_bytes_written += bytes_written
                except socket.timeout:
                    pass
                except socket.error as why:
                    if why.args[0] in (EWOULDBLOCK, EAGAIN):
                        continue
                    self._exceptions.append(AMQPConnectionError(why))
                    return
        finally:
            self._wr_lock.release()
21807
def write(self, data, dummy=None):
    """"""
    assert not self.closed
    if self.expected_write_data is None:
      return

    expected_data = self.expected_write_data.pop(0)
    if expected_data != data:
      raise ValueError('Expected %s, got %s (%s)' % (
          self._dotify(expected_data), binascii.hexlify(data),
          self._dotify(data)))
762252
def write_bytes(self, data: bytes, *, append=True):
        '''  '''
        mode = 'ab' if append else 'wb'
        return self.write(data, mode=mode)
147299
def _writeToTransport(self, data):
        ''''''
        self.transport.writeData(data)
        self.heartbeater.schedule()
220334
def writeByte(self, byte):
        
        self.data.write(pack("B" if not self.signed else "b", byte))
1259542
def write(self, data):
        '''
        
        '''
        # MUST use a lock here else gevent could raise an exception if 2
        # greenlets try to write at the same time. I was hoping that
        # sendall() would do that blocking for me, but I guess not. May
        # require an eventsocket-like buffer to speed up under high load.
        self._write_lock.acquire()
        try:
            return super(GeventTransport, self).write(data)
        finally:
            self._write_lock.release()
938043
def write(self, data):
        
        self._check_can_write()
        compressed = self._compressor.compress(data)
        self._fp.write(compressed)
        self._pos += len(data)
        return len(data)
210777
def write_message(self, data, binary=False):
        
        self.connection.write_message(data, binary)
795833
def write(self, data):
        

        while data:
            try:
                n = self._socket.send(data)
            except socket.error:
                n = None
            if not n:
                raise EOFError('Socket closed')
            data = data[n:]
783420
def send(self, data: bytes = b""):
        
        self.input.extend(data)
        self._process()
852168
def write(self, data):
        
        for _ in range(64 - len(data)):
            data.append(0)
        #logging.debug("send: %s", data)
        self.report.send(bytearray([0]) + data)
        return
400353
public void sendMessage(byte data)
    {
        try
        {
            out.write(data);
            out.flush();
        }
        catch (final IOException exception)
        {
            Verbose.exception(exception);
        }
    }
732519
def send_body(self, data):
        

        if type(data) is str:
            data = data.encode()
        self.connection.writer.write(data)
        yield from self.connection.writer.drain()