osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

if STREAM.isatty():


On Thu, 29 Aug 2019 13:23:07 +0100, Rhodri James wrote:

> TLDR: these two lines set up (but don't output) a progress message for
> an interactive stream.

Thanks a lot for your deeply notes on this.  But, if so, when will the 
``else ...'' be executed in the original code:


        if STREAM.isatty():
            p = (self.progress_template + '\r') % params
        else:
            current_time = time.time()
            if self._last_time == 0.0:
                self._last_time = current_time
            else:
                interval = current_time - self._last_time
                if interval < 0.5:
                    return
                self._last_time = current_time
            p = (self.progress_template + '\n') % params
        STREAM.write(p)
        STREAM.flush()


Regards