robertoszek / pleroma-bot

Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon/Misskey.
https://robertoszek.github.io/pleroma-bot
MIT License
102 stars 19 forks source link

tqdm breaks distinction of stdout/ stderr #108

Closed selyod-ka closed 1 year ago

selyod-ka commented 1 year ago

Hey!

I'm letting run pleroma-bot regularly via cron and let stdout go to /dev/null. If there were errors, I was informed by mail. (as per docs: https://robertoszek.github.io/pleroma-bot/gettingstarted/automateit/)

As far as I understand, the inclusion of tqdm breaks this workflow, as I have to decide to either receive mails on every run containing little useful information...

Gathering tweets... 0
Gathering tweets... 5
Gathering tweets... 5

Processing tweets... :   0%|          | 0/5 [00:00<?, ?it/s]
Processing tweets... : 100%|██████████| 5/5 [00:00<00:00, 881.97it/s]
[...]

... or not get notified about errors by also redirecting stderr to /dev/null

I have not yet understood how to modify tqdm.

How do you cope with this problem? (Is there a way to setup pleroma-bot such that stderr does not contain INFO and progress bars?)

robertoszek commented 1 year ago

Hi! Right, tqdm outputs their progress bars to stderr and redirecting them to stdout is anything but straightforward... I can see how this would flood you with emails on every cronjob run, as it will always generate some output on stderr, sorry about that!

As far as I understand, by setting the disable tqdm parameter to None it will only enable progress bars on interactive TTYs. By doing that in theory they would be disabled when the bot is running in a cronjob, for example, but they would be enabled if you run it manually.

So, I've committed that change to the develop branch: https://github.com/robertoszek/pleroma-bot/commit/e2986ff63447c42edf59f3018781480e88052344

I've tested it on my system and cron stops sending emails after applying the change, please let me know if it helps on your machine or not. You can test it out by installing 1.2.1rc1:

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pleroma-bot==1.2.1rc1
selyod-ka commented 1 year ago

Very cool! Thank you!