'Send a command if connection has been established.
Args:
cmd (Command)
do_buffer (bool): Whether to buffer the message or always attempt
to send the command. This is mostly used to send an error
message if we\'re about to close the connection due our buffers
becoming full.'

def send_command(self, cmd, do_buffer=True):

    if (self.state == ConnectionStates.CLOSED):
        logger.info('[%s]    Not    sending,    connection    closed', self.id())
        return
    if (do_buffer and (self.state != ConnectionStates.ESTABLISHED)):
        self._queue_command(cmd)
        return
    self.outbound_commands_counter.inc(cmd.NAME)
    string = ('%s    %s' % (cmd.NAME, cmd.to_line()))
    if ('\n' in string):
        raise Exception('Unexpected    newline    in    command:    %r', string)
    self.sendLine(string.encode('utf-8'))
    self.last_sent_command = self.clock.time_msec()
