vistir.spin module

class vistir.spin.DummySpinner(text='', **kwargs)[source]

Bases: object

fail(exitcode=1, text='FAIL')[source]
hide_and_write(text, target=None)[source]
ok(text='OK')[source]
write(text=None)[source]
write_err(text=None)[source]
vistir.spin.SpinBase

alias of vistir.spin.DummySpinner

class vistir.spin.VistirSpinner(*args, **kwargs)[source]

Bases: vistir.spin.DummySpinner

A spinner class for handling spinners on windows and posix.

fail(text='FAIL', err=False)[source]

Set fail finalizer to a spinner.

hide_and_write(text, target=None)[source]
ok(text='OK', err=False)[source]

Set Ok (success) finalizer to a spinner.

start()[source]
stop()[source]
write(text)[source]
write_err(text)[source]

Write error text in the terminal without breaking the spinner.

vistir.spin.decode_output(output, target_stream=None, *, translation_map={10004: 'OK', 10008: 'x'})

Given a string, decode it for output to a terminal.

Parameters:
  • output (str) – A string to print to a terminal
  • target_stream – A stream to write to, we will encode to target this stream if possible.
  • translation_map (dict) – A mapping of unicode character ordinals to replacement strings.
Returns:

A re-encoded string using the preferred encoding

Return type:

str

vistir.spin.handler(signum, frame, spinner)[source]

Signal handler, used to gracefully shut down the spinner instance when specified signal is received by the process running the spinner.

signum and frame are mandatory arguments. Check signal.signal function for more details.