Git Product home page Git Product logo

halo's Introduction


halo

Build Status Build status Coverage Status PyPI awesome Downloads Downloads

Beautiful spinners for terminal, IPython and Jupyter

halo

Install

$ pip install halo

Usage

from halo import Halo

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

# Run time consuming work here
# You can also change properties for spinner as and when you want

spinner.stop()

Alternatively, you can use halo with Python's with statement:

from halo import Halo

with Halo(text='Loading', spinner='dots'):
    # Run time consuming work here

Finally, you can use halo as a decorator:

from halo import Halo

@Halo(text='Loading', spinner='dots')
def long_running_function():
    # Run time consuming work here
    pass

long_running_function()

API

Halo([text|text_color|spinner|animation|placement|color|interval|stream|enabled])

text

Type: str

Text shown along with spinner.

text_color

Type: str Values: grey, red, green, yellow, blue, magenta, cyan, white

Color of the spinner text. Defaults to None.

spinner

Type: str|dict

If string, it should be one of the spinners listed in the given json file. If a dict is passed, it should define interval and frames. Something like:

{
    'interval': 100,
    'frames': ['-', '+', '*', '+', '-']
}

Defaults to dots spinner. For Windows users, it defaults to line spinner.

animation

Type: str Values: bounce, marquee

Animation to apply to the text if it's too large and doesn't fit in the terminal. If no animation is defined, the text will be ellipsed.

placement

Type: str Values: left, right

Which side of the text the spinner should be displayed. Defaults to left

color

Type: str Values: grey, red, green, yellow, blue, magenta, cyan, white

Color of the spinner. Defaults to cyan.

interval

Type: float

Interval between each frame. Defaults to spinner interval (recommended).

stream

Type: file

Stream to write the output. Defaults to sys.stdout.

enabled

Type: bool

Enable or disable the spinner. Defaults to True.

Methods

Following are the methods available:

spinner.start([text])

Starts the spinner. If text is passed, it is set as spinner text. Returns the instance.

spinner.stop()

Stops and clears the spinner. Returns the instance.

spinner.clear()

Clears the spinner. Returns the instance.

spinner.render()

Manually renders a new frame. Returns the instance.

spinner.frame()

Returns next frame to be rendered.

spinner.succeed([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.fail([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.warn([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.info([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.stop_and_persist([symbol|text])

Stops the spinner and changes symbol and text. Returns the instance.

symbol

Type: str

Symbol to replace the spinner with. Defaults to ' '.

text

Type: str

Text to be persisted. Defaults to instance text.

Persist spin

spinner.text

Change the text of spinner.

spinner.color

Change the color of spinner

spinner.spinner

Change the spinner itself.

spinner.enabled

Enable or disable the spinner.

How to contribute?

Please see Contributing guidelines for more information.

Like it?

🌟 this repo to show support. Let me know you liked it on Twitter. Also, share the project.

Related

  • py-spinners - Spinners in Python
  • py-log-symbols - Log Symbols in Python
  • ora - Elegant terminal spinners in JavaScript (inspiration behind this project)

License

MIT © Manraj Singh

halo's People

Contributors

0scarb avatar adamtheturtle avatar alarreine avatar andreskrey avatar caiocarrara avatar cschubes avatar ellisonleao avatar evasseure avatar goggle avatar krischer avatar lilja avatar manrajgrover avatar niloch avatar saipathuri avatar slmingol avatar steelman avatar stephen-bunn avatar they4kman avatar ushpizin avatar vilhelmprytz avatar vmalloc avatar winterjung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

halo's Issues

Upgrade to six==1.12.0

Description

Can Halo be upgraded to use six version 1.12.0? The tensorflow pip package depends on 1.12.0, making it completely incompatible with halo.

Bug: Long texts length is not matching output area in Jupyter

Description

Currently, on using long texts with animations in Jupyter results in output wrapping in next line. Fix for this would be to give it a fixed layout width or try and get the width of display area while creating frames.

System settings

  • Operating System: Mac OS
  • Terminal in use: NA
  • Python version: 2.7.14
  • Halo version: HEAD
  • pip freeze output: NA

Error

Output wraps in display area for Jupyter notebook when long texts are used.

Expected behaviour

Output should take width of display area before creating frames.

Steps to recreate

longtext

People to notify

@jungwinter @manrajgrover

Low-overhead version for use in other code

This is a really slick implementation. Congrats.

It is pretty trivial to use pip, but It would be great if there was a bare-bones version that we could embed or import into existing code, w/o requiring the user to install any other libraries.

What is the minimum set needed?

Version 3 support

Currently halo only supports version 2.
That'll be nice if we add version 3 support for halo.
Best of luck.

Bug: Cursor stays hidden after CTRL+C

Description

While a spinner is running, an unexpected exit of the script (like by pressing CTRL+C) makes the cursor stay hidden in the terminal.

System settings

  • Operating System: Void Linux
  • Terminal in use: kitty
  • Python version: 3.6.4
  • Halo version: 0.0.9 (latest)

Expected behaviour

The cursor should be made visible again.

Steps to recreate

Cancel this script:

from halo import Halo
import time
spinner = Halo()
spinner.start(text="Press Ctrl-C now")
time.sleep(999)

People to notify

@manrajgrover

Jupyter Notebooks don't support Halo

While Halo works perfectly fine in the terminal, I can't get Halo to work inside a Jupyter notebook. I am running the following code in the first cell of the notebook:

from halo import Halo
from time import sleep
with Halo(text='Loading', spinner='dots'):
    sleep(5)

The program runs through without any errors, but no spinner is shown at all.

I figured out, that if you write something to stdout with sys.stdout prior to calling Halo, then the spinner is shown, but each spinner and corresponding text are shown next to each other, i.e. clearing the current line doesn't work.

from halo import Halo
import sys
from time import sleep
sys.stdout.write('test\n')
with Halo(text='Loading', spinner='dots'):
    sleep(5)

returns the output

test
⠋ Loading⠙ Loading⠹ Loading⠸ Loading⠼ Loading⠴ Loading⠦ Loading⠧ Loading⠇ Loading⠏
Loading⠋ Loading⠙ Loading⠹ Loading⠸ Loading⠼ Loading⠴ Loading⠦ Loading⠧ Loading⠇
Loading⠏ Loading⠋ Loading⠙ Loading⠹ Loading⠸ Loading⠼ Loading⠴ Loading⠦ Loading⠧ 
Loading⠇ Loading⠏ Loading⠋ Loading⠙ Loading⠹ Loading⠸ Loading⠼ Loading⠴ Loading⠦ 
Loading⠧ Loading⠇ Loading⠏ Loading⠋ Loading⠙ Loading⠹ Loading⠸ Loading⠼ Loading⠴ 
Loading⠦ Loading⠧ Loading⠇ Loading⠏ Loading⠋ Loading⠙ Loading⠹ Loading⠸ Loading⠼ 
Loading⠴ Loading⠦ Loading⠧ Loading

Is there something wrong on my end, and do you have an idea how to fix that?
It would be really nice if Halo worked with Jupyter too. Thanks for your efforts and for sharing this library!

Bug: placement='right' in API doesn't work

Description

After adding placement='right' in the Halo constructor, the code gives an error that says "TypeError: init() got an unexpected keyword argument 'placement'".
Am I doing something wrong here?

from halo import Halo
import time

spinner = Halo(text='Loading', spinner='dots', placement='right')
spinner.start()

time.sleep(3)  # Running time-consuming work

spinner.stop()

System settings

  • Operating System: macOS
  • Terminal in use: iTerm2
  • Python version: 3.65
  • Halo version: 0.0.12
  • pip freeze output:
    backports.shutil-get-terminal-size==1.0.0
    colorama==0.3.9
    cursor==1.2.0
    enum34==1.1.6
    halo==0.0.12
    log-symbols==0.0.11
    six==1.11.0
    spinners==0.0.19
    termcolor==1.1.0

Error

Traceback (most recent call last):
File "main.py", line 8, in
spinner = Halo(text='Loading', spinner='dots', placement='right')
TypeError: init() got an unexpected keyword argument 'placement'

Expected behaviour

The spinner should be placed on the right of text.

Steps to recreate

People to notify

Demos: Move demo gifs to svg based demos

Description

Currently, we make use of gif demos, which is cool, but not as cool as svg-term-cli. Need to explore and move demos to svg based terminal sessions to improve documentation.

Bug: exceptions are swallowed by __exit__

Description

By returning a truthy value from __exit__, exceptions thrown when using Halo as a context manager are swallowed, and execution continues.

System settings

  • Python version: 3.6
  • Halo version: 0.0.18

Expected behaviour

✖ Doing the thing ...
Traceback (most recent call last):
  File "example.py", line 1337, in example
    raise Exception('stuff')
Exception: stuff

Steps to recreate

from halo import Halo

with Halo('Doing the thing ... '):
    # No exception seen
    raise Exception('stuff')
from halo import Halo

class TransparentHalo(Halo):
    def __exit__(self, exc_type, exc_value, traceback):
        super().__exit__(exc_type, exc_value, traceback)
        # no return

with TransparentHalo('Doing the thing ... '):
    raise Exception('stuff')

Why not use kwargs for options ?

Hi there, this is a question / enhancement proposal:

instead of relying on type checking, why not use keyword arguments to initialize a Halo instance ? This would be more Pythonic IMO (although, I realize filing an issue just to tell you that might make me sound like an a**hole).

This way, you would have more control about accepted arguments (nothing stops someone from creating an option dictionnary with nonsensical options, or maybe just a typo), and also expose the default values of arguments to the documentation / inline help of Halo:

class Halo(object):

    def __init__(self, text='', color='cyan', interval=-1, enabled=True, stream=sys.stdout):
        # ... #

Of course, this may cause problems for interval since it depends on the chosen spinner, but using None or -1 would probably do the trick.

Once again, this is just a suggestion !

Improve Windows Support

Currently, the package does not support Windows completely. Major reason for that is UTF-8 is not extensively supported by cmd, powershell etc.

KeyboardInterrupt: Should not persist text on CTRL+C

Description

Currently, we persist the text with failed symbol, which ideally should be done by the user if they want to show the text.

System settings

  • Operating System: NA
  • Terminal in use: NA
  • Python version: NA
  • Halo version: 0.0.9
  • pip freeze output: NA

Error

NA

Expected behaviour

On KeyboardInterrupt, no text should be persisted.

Steps to recreate

Run the following snippet and press CTRL+C.

from halo import Halo
import time
spinner = Halo()
spinner.start(text="Press Ctrl-C now")
time.sleep(999)

People to notify

@jungwinter

Improve test coverage

Description

Currently, the test coverage is around 88% which is okay but we can improve it. This issue focuses on adding tests covering missing branches.

People to notify

@manrajgrover

Add Documetation

Currently code is not documented, also documentation needs to be added

Bug: When used as a context manager, spinner starts itself

Description

When used as a context manager, a Halo spinner starts itself before .start() is called.

Expected behaviour

The spinner should not start until .start() is called explicitly

Steps to recreate

with Halo(color="grey",spinner="clock",placement="left", animation="marquee") as spinner:
    try:
        with db.authenticate_user as db_connection: #prompts for username/password, hidden if spinner is running
            spinner.start("doing something")
            #do something
    except DBException:
        spinner.fail("caught exception")

Merge the thing with tqdm

tqdm is a library doing the similar task: it creates not a spinner, but a progressbar. Consider merging the thing with tqdm.

Bug: Output gets hidden on stop_and_persist in Jupyter notebooks

Description

Currently, in jupyter notebooks, the final stop_and_persist output is not persisted. I've opened an issue in ipywidget for understanding the issue a little better (jupyter-widgets/ipywidgets#2072).

System settings

  • Operating System: Mac OS 10.13.1
  • Terminal in use: NA
  • Jupyter version: 4.4.0
  • Python version: 2.7.14
  • Halo version: 9f9ea37
  • pip freeze output: NA

Error

The output display is not persited on stop_and_persist call.

Expected behaviour

The output should be persited on stop_and_persist call.

Steps to recreate

widget bug

People to notify

@jungwinter @manrajgrover

Provide option to render more than one spinner at the same time

Suppose you get multiple long tasks at hand.
It should be nice to be able to start more than one spinner before finishing the last one

take this as an example:

 from halo import Hal
 
 a = start_task_a()
 a_spinner = Halo({'text': 'Do A', 'spinner': 'dots'})
 a_spinner.start()
 a_is_spinning = True
 
 b = start_task_b()
 b_spinner = Halo({'text': 'Do B', 'spinner': 'dots'})
 b_spinner.start()
 b_is_spinning = True
 
 while a_is_spinning or b_is_spinning:
     if a.is_finished():
         a_spinner.succeed()
         a_is_spinning = False
     if b.is_finished():
         b_spinner.succeed()
         b_is_spinning = False

Push README to Pypi

Currently, README is in markdown which is not supported by pypi. We need to convert the file to reStructuredText for pypi. This can be automated.

Bug: Bounce animation is not displaying full characters

Description

The last character of a bounce animation is never visible. Consider the case where the terminal width is 78 and the text width is 82. Animating with bounce will not show the last character.

System settings

  • Operating System: Win 10
  • Terminal in use: Git bash
  • Python version: 3.6.4
  • Halo version: Commit 0767ac1 / 0.0.17
  • pip freeze output: https://pastebin.com/iR79NRAA

Error

N/A

Expected behaviour

The last character should be shown.

Steps to recreate

I've written a test case that demonstrates the fault

    def test_bounce_animation(self):
        def filler_text(n_chars: int):
            return "_" * n_chars

        text = "{}abc".format(filler_text(80))

        expected_frames_without_appended_spinner = [
            "{}".format(filler_text(78)),
            "{}".format(filler_text(78)),
            "{}".format(filler_text(78)),
            "{}a".format(filler_text(77)),
            "{}ab".format(filler_text(76)),
            "{}abc".format(filler_text(75)),
            "{}abc".format(filler_text(75)),
            "{}ab".format(filler_text(76)),
            "{}a".format(filler_text(77)),
            "{}".format(filler_text(78)),
            "{}".format(filler_text(78)),
            "{}".format(filler_text(78)),
        ]
        # Prepend the actual spinner
        expected_frames = [
            "{0} {1}".format(frames[idx % frames.__len__()], frame)
            for idx, frame in enumerate(expected_frames_without_appended_spinner)
        ]
        spinner = Halo(text, animation="bounce", stream=self._stream)
        spinner.start()
        # Sleep a full bounce cycle
        time.sleep(1.2)
        spinner.stop()
        output = self._get_test_output()

        zippped_expected_and_actual_frame = zip(expected_frames, output)
        for multiple_frames in zippped_expected_and_actual_frame:
            expected_frame, actual_frame = multiple_frames
            self.assertEquals(expected_frame, actual_frame)

This will fail. However, changing

for x in range(0, text_length - terminal_width):

to

for x in range(0, text_length - terminal_width + 1):

resolves the test.

People to notify

Debug log on terminal

Hi,
when using Halo with boto3, I have a strange behaviour, all the debug log from boto are displayed
capture d ecran 2017-10-03 a 15 19 27
MacOS/Python3.6
halo (0.0.5)
boto3 (1.4.4)

Thanks

Synchronous spinner

Support synchronous spinners which switch frames upon explicit request from a working thread like.

with Halo(spinner='dots') as spinner:
  for f in files_to_load():
    spinner.next(text="Loading %s" %f) # or .step(), or .tick(), or…
    do_load_file(f)

This can (as far as I understand) be achieved with .frame() but isn't as concise as the above. Possibly don't render new frame more often than interval.

IPython dependency should be optional

halo currently requires IPython 5.x, meaning that project depending on it cannot use newer versions.

Logically I don't think it makes much sense because there are many uses to halo not involving IPython at all, meaning this dependency should be optional (i.e. extras)

Development: Check if stream is closed before calling clean up

Description

Currently, after every test tearDown is called which closes the stream. This throws an error after the test passes since clean up is called after every exit. Either we should not close stream after every test or we should check if stream is enabled on exit

System settings

  • Operating System: Any
  • Terminal in use: iTerm 2
  • Python version: 2.7.14
  • Halo version: HEAD
  • pip freeze output: NA

Error

See this

Expected behaviour

No error should be thrown.

Steps to recreate

Run tox

People to notify

None

Support custom spinners on Windows

Description

Currently, custom spinners provided by user is ignored mainly because of #5. We should allow custom spinners on Windows as well assuming user knows what he is doing.

Halo interfering with colorama brightness

In my program, I'm attempting to use the library Colorama to use terminal colors, and to brighten up text in my program. I'm also using halo for the spinners, but the two libraries conflict when a halo spinner is added.

Colorama's colored text automatically gets dimmed, and regardless if I disable the spinner, I'd have to brighten up each print statement, and every color change.

This appears to only be occurring on Windows, and in the default command prompt. I'm thinking the issue stems from changing the terminal color on your side.

Bug: UnicodeEncodeError when redirect stdout to a file

Description

I'm trying to use Halo in a CLI that can be called from a terminal directly or from a CI, when I try to redirect the stdout to a file I have this exception.

Example:

def my_cli_task:
    spinner = halo.Halo(enabled=True, spinner='dots')
    spinner.start(text="Starting")
    ...
    
    ...
    spinner.succeed('Complete')
    spinner.stop()

It works perfectly in the terminal but when I try to redirect the stdout to a file, it raise an exception.
e.g.:

$ ./my_example_cli_task.py > cli.log

System settings

  • Operating System: Ubuntu 18.04.1 LTS
  • Terminal in use: NA
  • Python version: Python 2.7.15rc1
  • Halo version: 0.0.21
  • pip freeze output:

Error

 Traceback (most recent call last):
  File "test.py", line 7, in <module>
    spin.start(text="Starting")
  File "/home/agustin/git/halo/halo/halo.py", line 423, in start
    self._render_frame()
  File "/home/agustin/git/halo/halo/halo.py", line 341, in _render_frame
    self._stream.write(output)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 166, in write_and_convert
    self.write_plain_text(text, cursor, start)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/usr/local/lib/python2.7/dist-packages/colorama/ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
UnicodeEncodeError: 'ascii' codec can't encode character u'\u280b' in position 0: ordinal not in range(128)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/agustin/git/halo/halo/halo.py", line 81, in clean_up
    self.stop()
  File "/home/agustin/git/halo/halo/halo.py", line 440, in stop
    self._spinner_thread.join()
  File "/usr/lib/python2.7/threading.py", line 929, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/agustin/git/halo/halo/halo.py", line 81, in clean_up
    self.stop()
  File "/home/agustin/git/halo/halo/halo.py", line 440, in stop
    self._spinner_thread.join()
  File "/usr/lib/python2.7/threading.py", line 929, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started

Expected behaviour

Print the my CLI log to a file

Steps to recreate

Redirect the stdout to file

People to notify

@alarreine

Bug: "Error in atexit._run_exitfuncs" when running unit tests

Description

I'm using the package within a download function like so:

def download(url):
  spinner = Halo(text='Downloading', spinner='dots12')
  spinner.start()
  (...)
  spinner.succeed('Download Complete')
  spinner.stop()

While, the package works as expected when running the program, when running unit test with pytest the test output is followed by the error message pasted below.

System settings

  • Operating System: macOS
  • Terminal in use: iTerm2
  • Python version: 3.5, 3.6, 3.7
  • Halo version: 0.0.17
  • pip freeze output:

Error

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 78, in clean_up
    self.stop()
  File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 419, in stop
    self.clear()
  File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 311, in clear
    self._stream.write('\r')
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "/usr/local/lib/python3.7/site-packages/_pytest/capture.py", line 358, in write
    self.buffer.write(obj)
ValueError: I/O operation on closed file
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 78, in clean_up
    self.stop()
  File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 419, in stop
    self.clear()
  File "/usr/local/lib/python3.7/site-packages/halo/halo.py", line 311, in clear
    self._stream.write('\r')
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "/usr/local/lib/python3.7/site-packages/colorama/ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "/usr/local/lib/python3.7/site-packages/_pytest/capture.py", line 358, in write
    self.buffer.write(obj)
ValueError: I/O operation on closed file

Expected behaviour

I wouldn't expect the package to have any impact on these tests that isn't present when running the program.

Steps to recreate

  • Run pytest unit tests on a program that uses halo as shown above

People to notify

Text in front of spinner

Not a real bug but a feature request.

It would be great if the Text could be in front of the spinner.

I created my own frames which gives me

. Loading
.. Loading
... Loading
..... Loading
...... Loading
....... Loading
...... Loading
..... Loading
.... Loading
... Loading
.. Loading
. Loading

:-) but I would like Loading in front (and keep loading as a text 👍 )

Bug: Spinner is not killed when parent thread throws an exception

Description

Currently, the thread is not killed when the parent thread throws an exception. A workaround for now is to catch the exception and stop the spinner manually.

System settings

  • Operating System: Any
  • Terminal in use: Any
  • Python version: 2.7.14 (actually any)
  • Halo version: 0.0.12
  • pip freeze output: NA

Error

Spinner keeps spinning when the exception is thrown on parent thread.

Expected behaviour

The spinner should be stopped when an exception is raised.

Steps to recreate

# -*- coding: utf-8 -*-
"""Example for doge spinner ;)
"""
from __future__ import unicode_literals
import os
import sys
import time

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath('.'))))

from halo import Halo

spinner = Halo(text='Such Spins', spinner='dots')


spinner.start()
time.sleep(2)
spinner.text = 'Much Colors'
spinner.color = 'magenta'
time.sleep(2)
spinner.text = 'Very emojis'
spinner.spinner = 'hearts'
raise Exception()
time.sleep(2)
spinner.stop_and_persist(symbol='🦄 '.encode('utf-8'), text='Wow!')

People to notify

@manrajgrover

Bug: Escape sequences leaking on stdout, even using the sys.stderr stream

Description

When using a spinner with stream=sys.stderr, the escape sequences to hide/show the terminal's cursor will still be outputed to stdout. They are visible if stdout is redirected to a file and opened in a text editor/cat -v, or directly piped to cat -v. This messes with the program's normal output in any case.

System settings

  • Operating System: Void Linux x64
  • Terminal in use: kitty, also tried on xterm
  • Python version: 3.6.4
  • Halo version: 0.0.8
  • pip freeze output:
    asciinema==1.4.0
    asn1crypto==0.24.0
    attrs==17.4.0
    Automat==0.6.0
    backports.shutil-get-terminal-size==1.0.0
    cffi==1.11.2
    chardet==3.0.4
    colorama==0.3.9
    colored==1.3.5
    constantly==15.1.0
    cryptography==2.1.4
    cssselect==1.0.3
    cursor==1.1.0
    enum34==1.1.6
    flake8==3.5.0
    halo==0.0.8
    hererocks==0.17.0
    httplib2==0.10.3
    hyperlink==17.3.1
    idna==2.6
    incremental==17.5.0
    Jinja2==2.10
    log-symbols==0.0.12
    lxml==4.1.1
    MarkupSafe==1.0
    mccabe==0.6.1
    numpy==1.13.3
    openshot-qt==2.4.1
    pew==1.1.2
    pipenv==9.0.1
    psutil==5.4.2
    pyasn1==0.4.2
    pyasn1-modules==0.2.1
    Pybooru==4.1.0
    pycairo==1.15.4
    pycodestyle==2.3.1
    pycparser==2.18
    pyflakes==1.6.0
    Pygments==2.2.0
    PyGObject==3.27.1
    PyOpenGL==3.1.0
    PyOpenGL-accelerate==3.1.0
    pyOpenSSL==17.5.0
    pyPEG2==2.15.2
    python-mpv==0.3.8
    PyYAML==3.12
    pyzmq==16.0.3
    qutebrowser==1.0.4
    ranger==1.8.1
    requests==2.18.4

Steps to recreate

Run this script, piping its output to cat -v (e.g. python3 script | cat -v):

from halo import Halo
import sys
spinner = Halo(stream=sys.stderr)
spinner.start()
spinner.stop()
print("Testing")

People to notify

@manrajgrover

Bug: text input ignores leading spaces

Description

When supplying something such as spinner.start(text) with a string like " =>" it simply prints in the console as "=>"

System settings

  • Operating System: Arch Linus
  • Terminal in use: Kitty
  • Python version: 3.7.1
  • Halo version: 0.0.22
  • pip freeze output:
    appdirs==1.4.3 astroid==2.1.0 attrs==18.2.0 backcall==0.1.0 black==18.9b0 certifi==2018.10.15 chardet==3.0.4 Click==7.0 colorama==0.3.9 cursor==1.2.0 decorator==4.3.0 docutils==0.14 enum34==1.1.6 flit==1.2.1 halo==0.0.22 idna==2.7 invoke==1.2.0 ipython==7.1.1 ipython-genutils==0.2.0 isort==4.3.4 jedi==0.13.1 Jinja2==2.10 lazy-object-proxy==1.3.1 log-symbols==0.0.11 MarkupSafe==1.1.0 mccabe==0.6.1 -e git+https://gitlab.com/iboyperson/mkproj.git@a01e7b129add68051339c447debaa3b554ef0afd#egg=mkproj mypy==0.641 mypy-extensions==0.4.1 parso==0.3.1 pexpect==4.6.0 pickleshare==0.7.5 prompt-toolkit==2.0.7 ptyprocess==0.6.0 pycodestyle==2.4.0 pyflakes==2.0.0 Pygments==2.3.0 pylint==2.2.0 pytoml==0.1.20 requests==2.20.1 shellingham==1.2.7 six==1.11.0 spinners==0.0.23 termcolor==1.1.0 toml==0.10.0 traitlets==4.3.2 typed-ast==1.1.0 urllib3==1.24.1 wcwidth==0.1.7 wrapt==1.10.11

Expected behaviour

I would expect for the leading white-space to be included in the text shown in the command line.

Create development guide

Description

Currently, there is no documentation on how to set up the environment for developing and working on the library. This should be fixed.

System settings

  • Operating System: NA
  • Terminal in use: NA
  • Python version: NA
  • Halo version: NA
  • pip freeze output: NA

Error

NA

Expected behaviour

NA

Steps to recreate

NA

People to notify

NA

Bug: pip2 installation fails during parsing requirements.txt

Description

pip install halo fails and unable to install the module

System settings

  • Operating System: Windows 10 64bit
  • Terminal in use: Git bash
  • Python version: 2.7.10
  • Halo version: 0.0.17
  • pip freeze output:
alabaster==0.7.9
appdirs==1.2.0
astroid==1.4.9
autopep8==1.3.1
Babel==2.3.4
backports.ssl-match-hostname==3.4.0.2
bitstring==3.1.5
colorama==0.3.9
cov-core==1.15.0
coverage==3.7.1
crcmod==1.7
cycler==0.10.0
docutils==0.11
et-xmlfile==1.0.1
ez-setup==0.9
functools32==3.2.3.post2
imagesize==0.7.1
jdcal==1.2
Jinja2==2.7.2
lazy-object-proxy==1.3.1
logilab-common==0.61.0
lxml==3.4.0
MarkupSafe==0.18
matplotlib==2.0.0
mock==1.0.1
niScope==0.1
node==0.9.12
numpy==1.12.0+mkl
odict==1.5.1
openpyxl==2.4.2
pandas==0.19.2
Pillow==2.8.2
pluggy==0.4.0
plumber==1.2
py==1.4.30
py2exe==0.6.9
pycodestyle==2.3.1
Pygments==1.6
pylint==1.1.0
pyparsing==2.0.1
pyreadline==2.0
pyserial==2.7
PySide==1.2.2a0
pytest==2.7.2
pytest-capturelog==0.7
pytest-cov==1.6
pytest-quickcheck==0.8
python-dateutil==2.2
python-docx==0.8.5a0
pythonnet==2.3.0
pytz==2017.2
PyVISA==1.3b0
pywin32==219
PyYAML==3.12
requests==2.7.0
scipy==0.15.1
six==1.10.0
snowballstemmer==1.2.1
Sphinx==1.4.8
sphinx-rtd-theme==0.1.9
tornado==3.2
tox==2.6.0
tqdm==4.25.0
Unum==4.1.1
versioneer==0.18
virtualenv==14.0.6
wrapt==1.10.10
xlrd==0.9.3
XlsxWriter==0.7.7
xlwt==1.0.0
Yapsy==1.11.223
zope.component==4.2.0
zope.deprecation==4.1.0
zope.event==4.0.2
zope.interface==4.1.0
zope.lifecycleevent==4.0.3

BTW this also appears but is it better to do so?

You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Error

Collecting halo
  Using cached https://files.pythonhosted.org/packages/83/6e/b9e84a42281a3e4265d156cb75a8d7295e8be4bcab1545f0b59820e67e4b/halo-0.0.17.tar.gz
    Complete output from command python setup.py egg_info:
    error in halo setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifie
rs; Expected ',' or end-of-list in backports.shutil_get_terminal_size==1.0.0;python_version < '3.3' at ;python_version < '3.3'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\kyamamot\appdata\local\temp\pip-build-9hidlw\halo\
  • backports.shutil_get_terminal_size==1.0.0;python_version < '3.3' appears in requirement.txt

Expected behaviour

Installation succeeds

Disable spinners when not outputting to a TTY

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

  • Disable spinners when not outputting to a TTY

System settings

  • Operating System: Ubuntu 16.04.3 LTS
  • Python version: 3.6.3
  • Halo version: 0.0.10

Bug found on initializing text attribute

I found a bug, when you try to use "\n" escape in "text" attribute when you want to initialize your Halo object at first.

Just try Defining a Halo object like this

spinner = spinner = Halo({'text': 'Loading \n', 'spinner': 'dots'})
and then if you start it, its like you put it in a while loop and then start.

iPython notebook keyboard interrupt breaks cell when using Halo

Description

Currently, in an iPython notebook, if a user does not handle keyboard interrupt and the spinner is running, a KeyboardInterrupt is thrown but the spinner keeps spinning.

System settings

  • Operating System: MacOS
  • Terminal in use: iTerm 2
  • Python version: 2.7.10
  • Halo version: 0.0.8

Error

Expected behaviour

In [5]: import time
   ...: import random
   ...:
   ...: spinner.start()
   ...: for i in range(100):
   ...:     spinner.text = '{0}% Downloaded dataset.zip'.format(i)
   ...:     time.sleep(random.random())
   ...: spinner.succeed('Downloaded dataset.zip')
   ...:
⠹ 4% Downloaded dataset.zip^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-5-81a625f23371> in <module>()
      5 for i in range(100):
      6     spinner.text = '{0}% Downloaded dataset.zip'.format(i)
----> 7     time.sleep(random.random())
      8 spinner.succeed('Downloaded dataset.zip')
      9

KeyboardInterrupt:

⠼ 4% Downloaded

Steps to recreate

Following snippet should recreate the error.

In [1]: from halo import Halo

In [2]: spinner = Halo(text='Downloading dataset.zip', spinner='dots')

In [3]: import time
   ...: import random
   ...:
   ...: spinner.start()
   ...: for i in range(100):
   ...:     spinner.text = '{0}% Downloaded dataset.zip'.format(i)
   ...:     time.sleep(random.random())
   ...: spinner.succeed('Downloaded dataset.zip')

People to notify

@manrajgrover

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.