Exemple #1
0
class Spinner:
    def __init__(self, message):
        self.halo = Halo(text=message, spinner='dot', color='green')

    def __enter__(self):
        self.halo.__enter__()

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.halo.__exit__(exc_tb, exc_val, exc_tb)
Exemple #2
0
class StatusMessage:
    """A generic class to provide status updates to the UI.

    At the moment only a text user interface is supported so this simply passes
    messages along to `Halo`.

    """
    def __init__(self, text=None):
        self.spinner = Halo(text, spinner='dots')

    def __enter__(self, text=None):
        self.spinner.__enter__()
        return self

    def __exit__(self, exc_type, exc_value, exc_traceback):
        self.spinner.__exit__(exc_type, exc_value, exc_traceback)

    def update(self, text):
        self.spinner.text = text