Sends a string to the host.

 This does _not_ automatically append a newline to the string.  Embedded
 newlines may be converted and telnet command sequences escaped
 depending upon the values of telnetmode, binmode, and telnet options
 set by the host.
187737
def print(string)
      string = string.gsub(/#{IAC}/no, IAC + IAC) if @options["Telnetmode"]

      if @options["Binmode"]
        self.write(string)
      else
        if @telnet_option["BINARY"] and @telnet_option["SGA"]
          # IAC WILL SGA IAC DO BIN send EOL --> CR
          self.write(string.gsub(/\n/n, CR))
        elsif @telnet_option["SGA"]
          # IAC WILL SGA send EOL --> CR+NULL
          self.write(string.gsub(/\n/n, CR + NULL))
        else
          # NONE send EOL --> CR+LF
          self.write(string.gsub(/\n/n, EOL))
        end
      end
    end
1099252
def _send_string(self,value):
        

        if type(value) != bytes:
            value = "{}".format(value).encode("ascii")

        return value
560664
def _send_string_clipboard(self, string: str, paste_command: model.SendMode):
        
        backup = self.clipboard.text  # Keep a backup of current content, to restore the original afterwards.
        if backup is None:
            logger.warning("Tried to backup the X clipboard content, but got None instead of a string.")
        self.clipboard.text = string
        try:
            self.mediator.send_string(paste_command.value)
        finally:
            self.ungrab_keyboard()
        # Because send_string is queued, also enqueue the clipboard restore, to keep the proper action ordering.
        self.__enqueue(self._restore_clipboard_text, backup)
1363184
def send_line(self, data, nowait=False):
        """"""
        data = data.replace('\n', ' ').replace('\r', ' ')
        f = asyncio.Future(loop=self.loop)
        if self.queue is not None and nowait is False:
            self.queue.put_nowait((f, data))
        else:
            self.send(data.replace('\n', ' ').replace('\r', ' '))
            f.set_result(True)
        return f
588154
def send(self, s):
        
        self._print_header('======== Sending ({0}) ========'.format(len(s)))

        self._log_send(s)
        out = len(s)

        while s:
            s = s[self._send(s):]
        return out
1301232
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT):
        """"""
        # This is a quick test to see if we can parse the packets we generate
        #temp = DNSIncoming(out.packet())
        for i in self.intf.values():
            try:
                return i.sendto(out.packet(), 0, (addr, port))
            except:
                traceback.print_exc()
                # Ignore this, it may be a temporary loss of network connection
                return -1
547460
def send(self, target, nick, msg, msgtype, ignore_length=False, filters=None):
        
        if not isinstance(msg, str):
            raise Exception("Trying to send a %s to irc, only strings allowed." % type(msg).__name__)
        if filters is None:
            filters = self.outputfilter[target]
        for i in filters:
            if target != self.config['core']['ctrlchan']:
                msg = i(msg)
        # Avoid spam from commands that produce excessive output.
        if not ignore_length:
            # Ignore everything after the first 800 chars.
            msg = misc.truncate_msg(msg, 800)

        # We can't send messages > 512 bytes to irc.
        max_len = misc.get_max_length(target, msgtype)
        msgs = self.build_split_msg(msg, max_len)

        for i in msgs:
            self.do_log(target, nick, i, msgtype)
            if msgtype == 'action':
                self.rate_limited_send('action', target, i)
            else:
                self.rate_limited_send('privmsg', target, i)
832325
def send_command(self, command: str, *args, **kwargs):
        
        info = 'send command `%s` to bot. Args: %s | Kwargs: %s'
        self._messaging_logger.command.info(info, command, args, kwargs)

        command = command.encode('utf8')
        # target = target.encode('ascii')
        args = _json.dumps(args).encode('utf8')
        kwargs = _json.dumps(kwargs).encode('utf8')
        frame = (b'', command, args, kwargs)
        debug = ' send command run_control_loop: %s'
        self._messaging_logger.command.debug(debug, self._run_control_loop)

        if self._run_control_loop:
            self.add_callback(self.command_socket.send_multipart, frame)
        else:
            self.command_socket.send_multipart(frame)
1201207
def _echo_byte(self, byte):
        
        if byte == '\n':
            self.send_buffer += '\r'
        if self.telnet_echo_password:
            self.send_buffer += '*'
        else:
            self.send_buffer += byte
456697
def sendline(self, data, linesep=os.linesep):
        '''
        
        '''
        return self.send('{0}{1}'.format(data, linesep))
718088
def msg(self, msg, *args):
        
        if self.debuglevel > 0:
            self.stderr.write('Telnet(%s,%d): ' % (self.host, self.port))
            if args:
                self.stderr.write(msg % args)
            else:
                self.stderr.write(msg)
            self.stderr.write('\n')
1288333
def _send_string_selection(self, string: str):
        """"""
        backup = self.clipboard.selection  # Keep a backup of current content, to restore the original afterwards.
        if backup is None:
            logger.warning("Tried to backup the X PRIMARY selection content, but got None instead of a string.")
        self.clipboard.selection = string
        self.__enqueue(self._paste_using_mouse_button_2)
        self.__enqueue(self._restore_clipboard_selection, backup)
746419
def send_to_new_instance(*args)
      id = Identifier.allocate
      id.instance_variable_set :@wrapped_string, to_s
      id.send(*args)
      id
    end
264125
def _send_cmd(self, cmd: str):
        """"""
        self._sock.sendall(cmd.encode(encoding='latin-1', errors='strict'))
1310683
def write_to_string
      string_io = StringIO.new.set_encoding(Encoding::BINARY)
      write_to_string_io(string_io)
      string_io.string
    end
8787
def sendcommand(self, command, datalength=0, data=None):
        ''''''
        packet = chr(Vendapin.STX) + chr(Vendapin.ADD) + chr(command) + chr(datalength)
        if datalength > 0:
            packet += chr(data)
        packet += chr(Vendapin.ETX)
        sendpacket = packet + chr(self._checksum(packet))
        self._printpacket(sendpacket)
        self.serial.write(sendpacket)
921137
def send_command(self, *args, **kwargs):
        
        if len(args) >= 1:
            command_string = args[0]
        else:
            command_string = kwargs["command_string"]

        # If changeto in command, look for '#' to determine command is done
        if "changeto" in command_string:
            if len(args) <= 1:
                expect_string = kwargs.get("expect_string", "#")
                kwargs["expect_string"] = expect_string
        output = super(CiscoAsaSSH, self).send_command(*args, **kwargs)

        if "changeto" in command_string:
            self.set_base_prompt()

        return output