Skip to content

Conversation

danielpanteleit
Copy link
Contributor

When running python scripts that use tqdm in cron jobs; i noticed that the output of tqdm is also redirected. I changed the disable parameter, so if it is not set explicitly, the output will be disabled automatically if the output file is not a TTY (i.e. is some sort of redirection).

@lrq3000 lrq3000 added the p3-enhancement 🔥 Much new such feature label Oct 7, 2016
@lrq3000
Copy link
Member

lrq3000 commented Oct 7, 2016

Hmmm I'm hesitant about this. Outputting to a non-TTY might be wanted, for example I'm not sure that a jupyter notebook would be detected as a tty. Also the output might be wanted in a log.

So this needs to be further tested on various environments before merging, we should be careful about this. If it can't be merged, we could add this as an example use case in the README.

@codecov-io
Copy link

codecov-io commented Oct 9, 2016

Current coverage is 90.43% (diff: 100%)

Merging #281 into master will increase coverage by 0.03%

@@             master       #281   diff @@
==========================================
  Files             7          7          
  Lines           479        481     +2   
  Methods           0          0          
  Messages          0          0          
  Branches         86         87     +1   
==========================================
+ Hits            433        435     +2   
  Misses           44         44          
  Partials          2          2          

Powered by Codecov. Last update bc9d113...9003e92

@danielpanteleit
Copy link
Contributor Author

I changed the default for disable back to False. Now you can set it explicitly to None to make it auto-detect TTY and disable it on non-TTY. This way there won't be any problems for existing code using tqdm.

We could think about using some constant like tqdm.AUTO instead of None though if you want.

@lrq3000
Copy link
Member

lrq3000 commented Oct 16, 2016

@danielpanteleit Thank's a lot, you even made the unit tests, so I'm merging this right in!

Self note: this will maybe have to moved to tqdm_auto #234 when (if ever) it will be done, but meanwhile this will solve some issues.

@lrq3000 lrq3000 merged commit bde013b into tqdm:master Oct 16, 2016
@casperdcl
Copy link
Member

thanks @danielpanteleit feel free to 👍 this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-enhancement 🔥 Much new such feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants