'Returns the stdout/stderr output from a ssh channel as a list of
strings (non-interactive only)'

def _get_output(self, channel, silent=True, only_printable=False):

    stdout = channel.makefile('rb', (-1))
    stderr = channel.makefile_stderr('rb', (-1))
    if silent:
        output = (stdout.readlines() + stderr.readlines())
    else:
        output = []
        line = None
        while (line != ''):
            line = stdout.readline()
            if only_printable:
                line = ''.join((c for c in line if (c in string.printable)))
            if (line != ''):
                output.append(line)
                print line,
        for line in stderr.readlines():
            output.append(line)
            print line,
    if only_printable:
        output = map((lambda line: ''.join((c for c in line if (c in string.printable)))), output)
    output = map((lambda line: line.strip()), output)
    return output
