Sends a given command to the HAProxy control socket.

        Returns the response from the socket as a string.

        If a known error response (e.g. "Permission denied.") is given then
        the appropriate exception is raised.
549014
def send_command(self, command):
        
        logger.debug("Connecting to socket %s", self.socket_file_path)
        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        try:
            sock.connect(self.socket_file_path)
        except IOError as e:
            if e.errno == errno.ECONNREFUSED:
                logger.error("Connection refused.  Is HAProxy running?")
                return
            else:
                raise

        sock.sendall((command + "\n").encode())

        response = b""
        while True:
            try:
                chunk = sock.recv(SOCKET_BUFFER_SIZE)
                if chunk:
                    response += chunk
                else:
                    break
            except IOError as e:
                if e.errno not in (errno.EAGAIN, errno.EINTR):
                    raise

        sock.close()

        return self.process_command_response(command, response)
551336
private void status(String command, Socket socket) throws IOException {
        lock.lock();
        try {
            String status = "{}"; // TODO Possibly have something more interesting to report.
            DataOutputStream dout = new DataOutputStream(socket.getOutputStream());

            byte[] statusBytes = status.getBytes(utf8);
            dout.writeInt(statusBytes.length);
            dout.write(statusBytes);

            dout.flush();
        } finally {
            lock.unlock();
        }
    }
533884
def send(self, load, tries=None, timeout=None, raw=False):  # pylint: disable=unused-argument
        '''
        
        '''
        if 'cmd' not in load:
            log.error('Malformed request, no cmd: %s', load)
            return {}
        cmd = load['cmd'].lstrip('_')
        if cmd in self.cmd_stub:
            return self.cmd_stub[cmd]
        if not hasattr(self.fs, cmd):
            log.error('Malformed request, invalid cmd: %s', load)
            return {}
        return getattr(self.fs, cmd)(load)
199060
def send(self, commands):
        ""
        if not commands.endswith("\n"):
            commands += "\n"
        self.sock.send(commands)
759083
public boolean sendCommand(String command) {
        if (writer != null) {
            try {
                logger.info("Sending command " + command + " to remote host " + remoteHost);
                writer.write(command);
                writer.write('\r');
                writer.flush();
            } catch (IOException e) {
                logger.fatal("Error while sending command " + command + " to remote host " + remoteHost, e);
                return false;
            }
            return true;
        } else {
            return false;
        }
    }
1122364
def sendCommand(self, command):
        
        command_data = [ord(x) for x in buffer(command)]
        self.hid.write(command_data)
        response_data = ''.join(chr(x) for x in self.hid.read(64))
        response = command.RESPONSE.from_buffer_copy(response_data)
        if response.status != 0:
            raise CommandException(response.status)
        return response
662879
def _send_command(self, method_name, data=None):
        
        try:
            response = self.lib.post(self._tpl_url % {'token': self.auth_token, 'method': method_name}, data=data)
            json = response.json()

            if not json['ok']:
                raise TelegramMessengerException(json['description'])

            return json['result']

        except self.lib.exceptions.RequestException as e:
            raise TelegramMessengerException(e)
264125
def _send_cmd(self, cmd: str):
        """"""
        self._sock.sendall(cmd.encode(encoding='latin-1', errors='strict'))
403666
def _send_command(self, cmd, expect=None):
        
        if not self.is_alive:
            raise NotPlayingError()
        logger.debug("Send command to mplayer: " + cmd)
        cmd = cmd + "\n"
        # In Py3k, TypeErrors will be raised because cmd is a string but stdin
        # expects bytes. In Python 2.x on the other hand, UnicodeEncodeErrors
        # will be raised if cmd is unicode. In both cases, encoding the string
        # will fix the problem.
        try:
            self.sub_proc.stdin.write(cmd)
        except (TypeError, UnicodeEncodeError):
            self.sub_proc.stdin.write(cmd.encode('utf-8', 'ignore'))
        time.sleep(0.1)     # wait for mplayer (better idea?)
        # Expect a response for 'get_property' only
        if not expect:
            return
        while True:
            try:
                output = self.sub_proc.stdout.readline().rstrip()
                output = output.decode('utf-8')
            except IOError:
                return None
            # print output
            split_output = output.split('=')
            # print(split_output)
            if len(split_output) == 2 and split_output[0].strip() == expect:
                # We found it
                value = split_output[1]
                return value.strip()
153866
def send_packed_command(self, command):
        ""
        if not self._sock:
            self.connect()
        try:
            if isinstance(command, str):
                command = [command]
            for item in command:
                self._sock.sendall(item)
        except socket.timeout:
            self.disconnect()
            raise TimeoutError("Timeout writing to socket")
        except socket.error:
            e = sys.exc_info()[1]
            self.disconnect()
            if len(e.args) == 1:
                errno, errmsg = 'UNKNOWN', e.args[0]
            else:
                errno = e.args[0]
                errmsg = e.args[1]
            raise ConnectionError("Error %s while writing to socket. %s." %
                                  (errno, errmsg))
        except:  # noqa: E722
            self.disconnect()
            raise
326975
async def send_rpc(self, conn_id, address, rpc_id, payload, timeout):
        

        self._ensure_connection(conn_id, True)
        connection_string = self._get_property(conn_id, "connection_string")

        msg = dict(address=address, rpc_id=rpc_id, payload=base64.b64encode(payload),
                   timeout=timeout, connection_string=connection_string)

        response = await self._send_command(OPERATIONS.SEND_RPC, msg, COMMANDS.SendRPCResponse,
                                            timeout=timeout)

        return unpack_rpc_response(response.get('status'), response.get('payload'),
                                   rpc_id=rpc_id, address=address)
260204
def send(self, cmd, *payload):
        

        # If it's closed, raise an error up front
        if not self._sock:
            raise ConnectionClosed("Connection closed")

        # Construct the outgoing message
        msg = json.dumps(dict(cmd=cmd, payload=payload)) + '\n'

        # Send it
        try:
            self._sock.sendall(msg)
        except socket.error:
            # We'll need to re-raise
            e_type, e_value, e_tb = sys.exc_info()

            # Make sure the socket is closed
            self.close()

            # Re-raise
            raise e_type, e_value, e_tb
1243801
def SendCommand(self, Command):
        
        try:
            self._Api.send_command(Command)
        except SkypeAPIError:
            self.ResetCache()
            raise
712580
def execute_command(self, *args, **options):
        
        pool = self.connection_pool
        command_name = args[0]
        connection = pool.get_connection(command_name, **options)
        try:
            connection.send_command(*args)
            return self.parse_response(connection, command_name, **options)
        except ConnectionError:
            connection.disconnect()
            connection.send_command(*args)
            return self.parse_response(connection, command_name, **options)
        finally:
            pool.release(connection)
701356
def send_command_return(self, command, *arguments):
        
        return self.api.send_command_return(self, command, *arguments)
1282691
def _simple_command(self, command, arg=None, **kwargs):
    """"""
    self._protocol.send_command(command, arg)
    return self._protocol.handle_simple_responses(**kwargs)
975273
@Override
    public String sendCommand2(String command) throws IOException {
        String str = null;
        SshConnection ssh = null;
        try {
            ssh = SshConnectionFactory.getConnection(config.getGerritHostName(),
                    config.getGerritSshPort(), config.getGerritProxy(), config.getGerritAuthentication());
            str = ssh.executeCommand(command);
        } catch (Exception ex) {
            throw new IOException("Error during sending command", ex);
        } finally {
            if (ssh != null) {
                ssh.disconnect();
            }
        }
        return str;
    }