def report_stdout ( host , stdout ) : lines = stdout . readlines ( ) if lines : print ( "STDOUT from {host}:" . format ( host = host ) ) for line in lines : print ( line . rstrip ( ) , file = sys . stdout )
python how to analyze stdout line by line
Take a stdout and print it s lines to output if lines are present .
def report_stdout(host, stdout):
    """Take a stdout and print it's lines to output if lines are present.

    :param host: the host where the process is running
    :type host: str
    :param stdout: the std out of that process
    :type stdout: paramiko.channel.Channel
    """
    lines = stdout.readlines()
    if lines:
        print("STDOUT from {host}:".format(host=host))
        for line in lines:
            print(line.rstrip(), file=sys.stdout)