'Generic handler that will read all the data from an SSH or telnet channel.'

def _read_channel(self):

    if (self.protocol == u'ssh'):
        output = u''
        while True:
            if self.remote_conn.recv_ready():
                outbuf = self.remote_conn.recv(MAX_BUFFER)
                if (len(outbuf) == 0):
                    raise EOFError(u'Channel    stream    closed    by    remote    device.')
                output += outbuf.decode(u'utf-8', u'ignore')
            else:
                break
    elif (self.protocol == u'telnet'):
        output = self.remote_conn.read_very_eager().decode(u'utf-8', u'ignore')
    log.debug(u'read_channel:    {}'.format(output))
    return output
