'Read lines from a subprocess\' output stream and either pass to a progress
callable (if specified) or write progress information to sys.stderr.'

def reader(self, stream, context):

    progress = self.progress
    verbose = self.verbose
    while True:
        s = stream.readline()
        if (not s):
            break
        if (progress is not None):
            progress(s, context)
        else:
            if (not verbose):
                sys.stderr.write('.')
            else:
                sys.stderr.write(s.decode('utf-8'))
            sys.stderr.flush()
    stream.close()
