homura icon indicating copy to clipboard operation
homura copied to clipboard

Print progress on one line

Open ellieLitwack opened this issue 7 years ago • 3 comments

I'm running on OS X, and the progress function would print a new line every time it updated. I made this change so that the progress function would update the same line every time, keeping the terminal output cleaner - let me know what you think!

Before this PR screen shot 2017-05-17 at 10 44 07 am

After this PR screen shot 2017-05-17 at 10 43 28 am

ellieLitwack avatar May 17 '17 14:05 ellieLitwack

@eliLitwack , thanks for PR. I'm not sure how you run the program, but my code detects whether the user is connected to a tty device (e.g. run from your terminal session). If it is tty, it will refresh the line (print one line), otherwise it will print a new line for each one (e.g. when you redirect the output to a file). See https://github.com/shichao-an/homura/blob/master/homura.py#L265

shichao-an avatar May 17 '17 18:05 shichao-an

Ah okay - I've been running it from an IDE (PyCharm), so I guess that explains it.

ellieLitwack avatar May 17 '17 18:05 ellieLitwack

could you change the code of homura to if STREAM.isatty() or 'PYCHARM_HOSTED' in os.environ: This would detect pycharm correctly as one-line-printable. I have the same problem as @ellieLitwack

LukasWestholt avatar Feb 15 '19 21:02 LukasWestholt