manrajgrover / halo

💫 Beautiful spinners for terminal, IPython and Jupyter
MIT License
2.89k stars 147 forks source link

Disable spinners when not outputting to a TTY #46

Closed vidyarani-dg closed 6 years ago

vidyarani-dg commented 6 years ago

I am using halo for the spinners and it works absolutely fine while running the management command from the command line, however I do not want the spinners while running my test suite. This is cluttering my tests and I want to disable it. I don't see an option to disable it. The only other option is to write the output to a file.

Is it possible to disable the spinners when not outputting to a TTY ?

Description

System settings

manrajgrover commented 6 years ago

@vidyarani-dg We do have an option for enabling and disabling the spinner. I believe you can disable it in your test environment using this.

vidyarani-dg commented 6 years ago

I see , thanks! It's clearly in the initialization. Sorry, I missed it.

Will close this issue.

manrajgrover commented 6 years ago

@vidyarani-dg Did it work as per your requirement?

vidyarani-dg commented 6 years ago

@ManrajGrover : Apologies for the tardiness in getting back to you, I did try

Halo(text='Loading files', enabled=False)

It did disable the info messages, however the errors are still outputting to the terminal.

Is this how it is supposed to work ?

manrajgrover commented 6 years ago

@vidyarani-dg Which errors are being outputted? I would need more information in order to assist.

vidyarani-dg commented 6 years ago

@ManrajGrover : Sorry, the failure messages . For instance, this is how I am using the spinner.

With enabled=False, I do not see any of the success / text messages on the terminal, however I do see the failure messages.

spinner = Halo(text='Loading files', spinner='dots', enabled=False)
spinner.start()

for row in rows:
    spinner.text = 'Processing line {}'.format(row.rownum)
    try:
        load(row)
    except Exception:
        spinner.fail("Error loading row {}".format(message)) # -> This is outputted to the terminal. 
        spinner.start()

spinner.succeed('Load successful, time taken in seconds: {}'.format((end - start).seconds))
spinner.stop()
manrajgrover commented 6 years ago

@vidyarani-dg Got it. Thanks for reporting this. I'll fix this and notify you with the release.

vidyarani-dg commented 6 years ago

Thank you.

manrajgrover commented 6 years ago

@vidyarani-dg Made a release with fix in v0.0.11. Please upgrade and check if it works as expected.