Enlighten Progress Bar is a console progress bar library for Python.

Overview
Documentation Status Travis-CI Build Status Coverage Status
Linux supported Windows supported MacOS supported BSD supported
PyPI Package latest release Supported versions Supported implementations
Latest Fedora Version Latest EPEL Version Latest Arch Linux Version Latest Debian Version Latest Ubuntu Version Latest Conda Forge Version

Overview

Enlighten Progress Bar is a console progress bar library for Python.

The main advantage of Enlighten is it allows writing to stdout and stderr without any redirection or additional code. Just print or log as you normally would.

Enlighten also includes experimental support for Jupyter Notebooks.


https://raw.githubusercontent.com/Rockhopper-Technologies/enlighten/master/doc/_static/demo.gif

The code for this animation can be found in demo.py in examples.

Documentation

https://python-enlighten.readthedocs.io

Installation

PIP

$ pip install enlighten

RPM

Fedora and EL8 (RHEL/CentOS)

(EPEL repositories must be configured for EL8)

$ dnf install python3-enlighten

EL7 (RHEL/CentOS)

(EPEL repositories must be configured)

$ yum install python2-enlighten
$ yum install python36-enlighten

PKG

Arch Linux

$ pacman -S python-enlighten

DEB

Debian and Ubuntu

$ apt-get install python3-enlighten

Conda

$ conda install -c conda-forge enlighten

Examples

Basic

For a basic status bar, invoke the Counter class directly.

import time
import enlighten

pbar = enlighten.Counter(total=100, desc='Basic', unit='ticks')
for num in range(100):
    time.sleep(0.1)  # Simulate work
    pbar.update()

Advanced

To maintain multiple progress bars simultaneously or write to the console, a manager is required.

Advanced output will only work when the output stream, sys.stdout by default, is attached to a TTY. get_manager can be used to get a manager instance. It will return a disabled Manager instance if the stream is not attached to a TTY and an enabled instance if it is.

import time
import enlighten

manager = enlighten.get_manager()
ticks = manager.counter(total=100, desc='Ticks', unit='ticks')
tocks = manager.counter(total=20, desc='Tocks', unit='tocks')

for num in range(100):
    time.sleep(0.1)  # Simulate work
    print(num)
    ticks.update()
    if not num % 5:
        tocks.update()

manager.stop()

Counters

The Counter class has two output formats, progress bar and counter.

The progress bar format is used when a total is not None and the count is less than the total. If neither of these conditions are met, the counter format is used:

import time
import enlighten

counter = enlighten.Counter(desc='Basic', unit='ticks')
for num in range(100):
    time.sleep(0.1)  # Simulate work
    counter.update()

Additional Examples

Customization

Enlighten is highly configurable. For information on modifying the output, see the Series and Format sections of the Counter documentation.

Comments
  • Some printed lines lost when resizing the terminal

    Some printed lines lost when resizing the terminal

    Describe the bug Resizing the terminal emulator may cause printed lines to be lost.

    To Reproduce Change the height of the terminal while the following program is running:

    import sys
    import time
    
    import enlighten
    
    with enlighten.get_manager() as manager:
        with manager.counter(total=30) as counter:
            for i in range(30):
                time.sleep(1)
                print(i)
                counter.update()
    

    Environment (please complete the following information):

    • Enlighten Version: 1.6.2
    • OS and version: Debian 10
    • Console application: GNOME Terminal 3.30.2 using VTE 0.54.2 +GNUTLS
    • Special Conditions: N/A

    Additional context The same problem happens with tmux and other terminal emulators.

    bug 
    opened by joreiff 19
  • enlighten for Windows

    enlighten for Windows

    Hi !

    This will probably be more an information than an issue: On Windows, the module does not working well. I've tried the following default below code:

    import time
    import enlighten
    
    manager = enlighten.get_manager()
    ticks = manager.counter(total=100, desc='Ticks', unit='ticks')
    tocks = manager.counter(total=20, desc='Tocks', unit='tocks')
    
    for num in range(100):
        time.sleep(0.1)  # Simulate work
        print(num)
        ticks.update()
        if not num % 5:
            tocks.update()
    
    manager.stop()
    

    And it looks like it does not working on Windows:

    image

    I also had the following error message:

    C:....\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT)

    I'm not sure if termios, fcntl and tty are mandatory, however termios is only available on Linux...

    Feature Request 
    opened by toshiro92 19
  • OSError: [WinError 6] The handle is invalid.

    OSError: [WinError 6] The handle is invalid.

    This error happens for all examples on the first page, as this one:

    import time
    import enlighten
    
    manager = enlighten.get_manager()
    ticks = manager.counter(total=100, desc='Ticks', unit='ticks')
    tocks = manager.counter(total=20, desc='Tocks', unit='tocks')
    
    for num in range(100):
        time.sleep(0.1)  # Simulate work
        print(num)
        ticks.update()
        if not num % 5:
            tocks.update()
    
    manager.stop()
    

    python3 version 3.7.2, Windows 10

    Traceback (most recent call last):
      File "D:\User\Downloads\text2.py", line 4, in <module>
        manager = enlighten.get_manager()
      File "F:\Python\lib\site-packages\enlighten\_manager.py", line 397, in get_manager
        return Manager(stream=stream, counterclass=counterclass, **kwargs)
      File "F:\Python\lib\site-packages\enlighten\_manager.py", line 78, in __init__
        self.term = Terminal(stream=self.stream)
      File "F:\Python\lib\site-packages\enlighten\_terminal.py", line 32, in __init__
        super(Terminal, self).__init__(*args, **kwargs)
      File "F:\Python\lib\site-packages\enlighten\_win_terminal.py", line 144, in __init__
        enable_vt_mode(self.stream_fh)
      File "F:\Python\lib\site-packages\enlighten\_win_terminal.py", line 109, in enable_vt_mode
        KERNEL32.GetConsoleMode(filehandle, ctypes.byref(current_mode))
      File "F:\Python\lib\site-packages\enlighten\_win_terminal.py", line 71, in _check_bool
        raise ctypes.WinError(ctypes.get_last_error())
    OSError: [WinError 6] The handle is invalid.
    
    opened by evandrocoan 16
  • "OSError: [WinError 0] The operation completed successfully." (PyCharm, Windows)

    Describe the bug Hey, first, thanks a lot for enlighten, I love the ideas you have put into it! :)

    I have the problem that a call to get_manager() will lead to the following error in my PyCharm console output WITH terminal emulation on Windows:

    Traceback (most recent call last): File "C:\Users\jschoena\AppData\Roaming\JetBrains\PyCharm2022.1\scratches\Test enlighten.py", line 4, in enlighten_manager = enlighten.get_manager(stream=sys.stdout, companion_stream=sys.stderr) File "C:\Users\jschoena.conda\envs\main\lib\site-packages\enlighten\manager.py", line 55, in get_manager return Manager(stream=stream, counter_class=counter_class, **kwargs) File "C:\Users\jschoena.conda\envs\main\lib\site-packages\enlighten_manager.py", line 70, in init super(Manager, self).init(**kwargs) File "C:\Users\jschoena.conda\envs\main\lib\site-packages\enlighten_basemanager.py", line 74, in init self.term = Terminal(stream=self.stream, kind=kind, force_styling=bool(kind)) File "C:\Users\jschoena.conda\envs\main\lib\site-packages\blessed\terminal.py", line 208, in init self.__init__keycodes() File "C:\Users\jschoena.conda\envs\main\lib\site-packages\blessed\terminal.py", line 331, in __init__keycodes self._encoding = get_console_input_encoding()
    File "C:\Users\jschoena.conda\envs\main\lib\site-packages\jinxed\win32.py", line 140, in get_console_input_encoding encoding = 'cp%d' % KERNEL32.GetConsoleCP() File "C:\Users\jschoena.conda\envs\main\lib\site-packages\jinxed\win32.py", line 86, in _check_bool raise ctypes.WinError(ctypes.get_last_error()) OSError: [WinError 0] The operation completed successfully.

    Process finished with exit code 1

    Even if I would catch the exception, the enlighten manager object is not created, thus I cannot continue from here.

    To Reproduce This snippet is enough:

    import enlighten
    
    enlighten_manager = enlighten.get_manager()
    
    print("Doesn't arrive here!")
    

    Environment:

    • Enlighten Version: 1.10.2 pyhd8ed1ab_0 conda-forge
    • OS and version: Windows Server 2019 Standard, 1809, OS build 17763.2803
    • Console application: PyCharm 2022.1, "Emulate terminal in output console" checked
    • Special Conditions: None, just executing script within IDE
    • Related packages:
      • blessed 1.19.1 py310h5588dad_1 conda-forge
      • python 3.10.4 hbb2ffb3_0 defaults
      • jinxed 1.1.0 py310h5588dad_2 conda-forge
    bug 
    opened by Jonibhoni 15
  • Sub-counters not available in counter_format

    Sub-counters not available in counter_format

    I would really like to display some other statistics/counters when in counter mode. It seems like the only way to do this is using sub-counters, but if I try to access a sub-counter in a counter_format, I get an error such as:

    KeyError: 'count_1'
    
    Feature Request 
    opened by edmcman 15
  • locale.Error: unsupported locale setting

    locale.Error: unsupported locale setting

    Not sure if it is related to the enlighten itself or the error is somewhere else, but I am receiving the following error:

    Traceback (most recent call last):
      File "bm_experiments/bm_DROP2.py", line 228, in <module>
        arg_params, path_expt = BmDROP2.main()
      File "~/Repos/BIRL/birl/benchmark.py", line 632, in main
        benchmark.run()
      File "~/Repos/BIRL/birl/utilities/experiments.py", line 139, in run
        self._run()
      File "~/Repos/BIRL/birl/benchmark.py", line 299, in _run
        aggr_experiments=True)
      File "~/Repos/BIRL/birl/benchmark.py", line 318, in __execute_method
        for res in iterate_mproc_map(method, iter_table, nb_workers=nb_workers, desc=desc):
      File "~/Repos/BIRL/birl/utilities/experiments.py", line 547, in iterate_mproc_map
        stream=sys.stderr)
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/enlighten/counter.py", line 31, in __init__
        counter_class=self.__class__, set_scroll=False)
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/enlighten/_manager.py", line 401, in get_manager
        return Manager(stream=stream, counterclass=counterclass, **kwargs)
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/enlighten/_manager.py", line 78, in __init__
        self.term = Terminal(stream=self.stream)
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/enlighten/_terminal.py", line 26, in __init__
        super(Terminal, self).__init__(*args, **kwargs)
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/blessed/terminal.py", line 238, in __init__
        self.__init__keycodes()
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/blessed/terminal.py", line 300, in __init__keycodes
        locale.setlocale(locale.LC_ALL, '')
      File "~/TEMP/Applications/vEnv3.6/lib/python3.6/locale.py", line 598, in setlocale
        return _setlocale(category, locale)
    locale.Error: unsupported locale setting
    

    Running on the following machine:

    • posix.uname_result(sysname='Linux', nodename='cmpgrid-68', release='4.9.0-6-amd64', version='#1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02)', machine='x86_64')
    • Python 3.6.6 (default, Mar 11 2019, 11:55:52) [GCC 7.3.0] on linux
    • pip 19.2.1 from /home.dokt/borovji3/TEMP/Applications/vEnv3.6/lib/python3.6/site-packages/pip (python 3.6)
    • enlighten==1.4.0
    Not a Bug 
    opened by Borda 13
  • Fix / Support for Screen ?

    Fix / Support for Screen ?

    I use screen to launch long running programs over SSH, and when I discovered Enlighten I figured it would be really cool to use it to monitor the running process.
    Unfortunately it seems enlighten doesn't like screen too much (or is it the terminal? sorry I'm new to the terminal world).

    • The loading character doesn't seem to be recognized
    • I use two progress bar, but the second one seems to multiply everytime it restarts to 0.

    image

    I don't know if it's relevant, but the program is running on a Debian 10 on a screen.xterm-256color terminal, to which I'm connected via SSH in a WSL environment using Windows Terminal.
    However everything looks nice in the same environment/terminal when I run it locally.

    Concerning the support requirements :

    • The terminal must be detectable programmatically echo $STY

    • Cursor movements I would guess that that comes from Xterm ?

    • Terminal dimensions tput cols / rows seems to work, not sure if that's enough.

    Tell me if I missed anything ;) thanks for you awesome work btw!

    Not a Bug 
    opened by GChalony 12
  • Invalid handle in PyCharm (Windows)

    Invalid handle in PyCharm (Windows)

    Hi, I am running enlighten-1.3.3 on Windows under Pycharm, and I always get a OSError: [WinError 6] The handle is invalid. error when I try to instantiate either a Counter or a Manager. I see there were similar issues raised here and here but if I understood correctly they should be fixed in this version.

    Did I misunderstand the other issues and is Pycharm simply not supported by enlighten? Or is there some way to fix this issue? Thanks

    opened by 4sfaloth 12
  • Human Readable Unit multipliers

    Human Readable Unit multipliers

    Is your feature request related to a problem? Please describe. For handling data, making the units able to be auto formatted as E/P/T/G/M/K{unit}ps would be awesome and improve human readability

    I'm not sure if this is best achieved by code that changes the units on the fly, but being able to mix units would also be reuqired, e.g. if using bytes, MB/s for speed and K/G/T/PM/s for size / total transfered - also being able to specify how many decimal places would be useful when formatting. For example 3.22GB/10.23TB 170MB/s, is there a way to easily do this or a way to add custom fields that use a callback and the callback gets passed the current data to be formatted?

    I thought about using custom fields but that would mean a lot of additional messy work.

    thoughts?

    Feature Request 
    opened by lps-rocks 11
  • Crash during window resizing

    Crash during window resizing

    Describe the bug When resizing the window the thread running enlighten crashes

    To Reproduce Resize window while running with multiple threads

    Environment (please complete the following information):

    • Enlighten Version: 1.6.0
    • OS and version: Debian 10 running Python 3.7.3
    • Console application: Terminal (mac) via SSH connection inside SCREEN
    • Special Conditions: None

    Additional context

    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/dist-packages/enlighten/_manager.py", line 275, in _resize_handler
        assert self.resize_lock
    AssertionError
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "./archive.py", line 633, in <module>
        status[r[0]].refresh()
      File "/usr/local/lib/python3.7/dist-packages/enlighten/_basecounter.py", line 230, in refresh
        flush=flush, counter=self)
      File "/usr/local/lib/python3.7/dist-packages/enlighten/_manager.py", line 472, in write
        stream.write(u'\r' + term.clear_eol + output)
      File "/usr/local/lib/python3.7/dist-packages/enlighten/_manager.py", line 303, in _resize_handler
        cter.refresh(flush=False)
      File "/usr/local/lib/python3.7/dist-packages/enlighten/_basecounter.py", line 230, in refresh
        flush=flush, counter=self)
      File "/usr/local/lib/python3.7/dist-packages/enlighten/_manager.py", line 472, in write
        stream.write(u'\r' + term.clear_eol + output)
    RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
    bug 
    opened by lps-rocks 11
  • 9 tests fail

    9 tests fail

    Describe the bug

    
    ========================================================================================== FAILURES ==========================================================================================
    ___________________________________________________________________________________ TestManager.test_init ____________________________________________________________________________________
    
    self = <tests.test_manager.TestManager testMethod=test_init>
    
        @unittest.skipIf(STDOUT_NO_FD, 'No file descriptor for stdout')
        def test_init(self):
            # Companion stream is __stderr__ if stream is __stdout__
        
            # Need to mock isatty() for some build and test environments
            with mock.patch.object(sys, '__stderr__') as mock_stderr:
                mock_stderr.isatty.return_value = True
                manager = enlighten.Manager(stream=sys.__stdout__)
        
    >       self.assertIs(manager.stream, sys.stdout)
    E       AssertionError: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> is not <_io.TextIOWrapper name="<_io.FileIO name=6 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'>
    
    tests/test_manager.py:55: AssertionError
    ___________________________________________________________________________________ TestManager.test_repr ____________________________________________________________________________________
    
    self = <tests.test_manager.TestManager testMethod=test_repr>
    
        def test_repr(self):
            manager = enlighten.Manager()
    >       self.assertEqual(repr(manager), "Manager(stream=%r)" % sys.stdout)
    E       AssertionError: "Manager(stream=<_io.TextIOWrapper name='[33 chars]8'>)" != 'Manager(stream=<_io.TextIOWrapper name="[75 chars]\'>)'
    E       - Manager(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)
    E       + Manager(stream=<_io.TextIOWrapper name="<_io.FileIO name=6 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'>)
    
    tests/test_manager.py:139: AssertionError
    __________________________________________________________________________ TestHTMLConverter.test_class_not_unique ___________________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_class_not_unique>
    
        def test_class_not_unique(self):
            """Repeated classes are dropped within the same span"""
        
    >       out = self.converter.to_html(self.term.blue_on_aquamarine(self.term.blue('blue_on_aquam')))
    
    tests/test_util.py:247: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    enlighten/_util.py:268: in to_html
        normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    .0 = <tuple_iterator object at 0x912d98130>
    
    >   normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    E   TypeError: 'Termcap' object is not subscriptable
    
    enlighten/_util.py:268: TypeError
    ________________________________________________________________________________ TestHTMLConverter.test_color ________________________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_color>
    
        def test_color(self):
            """Verify color conversion"""
        
            # CGA color on RGB color
    >       out = self.converter.to_html(self.term.blue_on_aquamarine('blue_on_aquam'))
    
    tests/test_util.py:117: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    enlighten/_util.py:268: in to_html
        normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <enlighten._util.Lookahead object at 0x918b28b50>, start = 0, stop = None
    
        def lookahead(self, start, stop=None):
            """
            Args:
                start(int): Positive integer index of first value
                stop(int): Positive integer index to end before (not returned)
        
            Retrieve next value(s) in iterator.
        
            start and stop roughly behave like slice notation, but must be positive
            """
        
            last = max(start, (stop or 0) - 1)
        
            while last >= len(self.buffer):
                try:
                    self.buffer.append(next(self.iterator))
                except StopIteration:
                    break
        
    >       return self.buffer[start] if stop is None else self.buffer[start:stop]
    E       IndexError: list index out of range
    
    enlighten/_util.py:163: IndexError
    _____________________________________________________________________________ TestHTMLConverter.test_empty_span ______________________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_empty_span>
    
        def test_empty_span(self):
            """Empty Spans are ignored"""
        
    >       out = self.converter.to_html(self.term.underline('') + 'empty')
    
    tests/test_util.py:241: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    enlighten/_util.py:268: in to_html
        normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    .0 = <tuple_iterator object at 0x9191f39d0>
    
    >   normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    E   TypeError: 'NoneType' object is not subscriptable
    
    enlighten/_util.py:268: TypeError
    ________________________________________________________________________________ TestHTMLConverter.test_style ________________________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_style>
    
        def test_style(self):
            """Verify style conversion"""
        
            # Italics
    >       out = self.converter.to_html(self.term.italic('italic'))
    
    tests/test_util.py:183: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    enlighten/_util.py:268: in to_html
        normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <enlighten._util.Lookahead object at 0x913854b50>, start = 0, stop = None
    
        def lookahead(self, start, stop=None):
            """
            Args:
                start(int): Positive integer index of first value
                stop(int): Positive integer index to end before (not returned)
        
            Retrieve next value(s) in iterator.
        
            start and stop roughly behave like slice notation, but must be positive
            """
        
            last = max(start, (stop or 0) - 1)
        
            while last >= len(self.buffer):
                try:
                    self.buffer.append(next(self.iterator))
                except StopIteration:
                    break
        
    >       return self.buffer[start] if stop is None else self.buffer[start:stop]
    E       IndexError: list index out of range
    
    enlighten/_util.py:163: IndexError
    ____________________________________________________________________________ TestHTMLConverter.test_style_output _____________________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_style_output>
    
        def test_style_output(self):
            """Verify style section output"""
        
    >       out = self.converter.to_html(self.term.red_on_slategrey('red_on_slategrey'))
    
    tests/test_util.py:256: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    enlighten/_util.py:268: in to_html
        normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <enlighten._util.Lookahead object at 0x9191f3100>, start = 0, stop = None
    
        def lookahead(self, start, stop=None):
            """
            Args:
                start(int): Positive integer index of first value
                stop(int): Positive integer index to end before (not returned)
        
            Retrieve next value(s) in iterator.
        
            start and stop roughly behave like slice notation, but must be positive
            """
        
            last = max(start, (stop or 0) - 1)
        
            while last >= len(self.buffer):
                try:
                    self.buffer.append(next(self.iterator))
                except StopIteration:
                    break
        
    >       return self.buffer[start] if stop is None else self.buffer[start:stop]
    E       IndexError: list index out of range
    
    enlighten/_util.py:163: IndexError
    _______________________________________________________________________ TestHTMLConverter.test_style_output_additional _______________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_style_output_additional>
    
        def test_style_output_additional(self):
            """Verify style section output with additional sections"""
        
            out = self.converter.to_html(self.term.blink('blink'))
    >       self.assertEqual(out, '<pre><span class="enlighten-blink">blink</span></pre>')
    E       AssertionError: '<pre>blink</pre>' != '<pre><span class="enlighten-blink">blink</span></pre>'
    E       - <pre>blink</pre>
    E       + <pre><span class="enlighten-blink">blink</span></pre>
    
    tests/test_util.py:280: AssertionError
    _____________________________________________________________________________ TestHTMLConverter.test_unsupported _____________________________________________________________________________
    
    self = <tests.test_util.TestHTMLConverter testMethod=test_unsupported>
    
        def test_unsupported(self):
            """Verify unsupported does not produce classes"""
        
            # Unsupported capability
            out = self.converter.to_html(self.term.move(5, 6) + 'unsupported_move')
            self.assertEqual(out, '<pre>unsupported_move</pre>')
        
            # Unsupported text attribute
    >       out = self.converter.to_html(self.term.reverse('unsupported_reverse'))
    
    tests/test_util.py:224: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    enlighten/_util.py:268: in to_html
        normal[1:] == [val[0] for val in parsed.lookahead(0, self.normal_rem or None)]:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <enlighten._util.Lookahead object at 0x915b77850>, start = 0, stop = None
    
        def lookahead(self, start, stop=None):
            """
            Args:
                start(int): Positive integer index of first value
                stop(int): Positive integer index to end before (not returned)
        
            Retrieve next value(s) in iterator.
        
            start and stop roughly behave like slice notation, but must be positive
            """
        
            last = max(start, (stop or 0) - 1)
        
            while last >= len(self.buffer):
                try:
                    self.buffer.append(next(self.iterator))
                except StopIteration:
                    break
        
    >       return self.buffer[start] if stop is None else self.buffer[start:stop]
    E       IndexError: list index out of range
    
    enlighten/_util.py:163: IndexError
    ====================================================================================== warnings summary ======================================================================================
    ../../../../../../usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
      /usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
        config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)
    
    -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    ================================================================================== short test summary info ===================================================================================
    SKIPPED [1] tests/test_notebook_manager.py:58: Notebook testing packages not installed
    ==================================================================== 9 failed, 120 passed, 1 skipped, 1 warning in 21.31s ====================================================================
    
    

    To Reproduce run pytest

    Environment (please complete the following information):

    • Enlighten Version: 1.11.0
    • OS and version: FreeBSD 13.1 STABLE
    • Console application: n/a
    • Special Conditions: n/a
    bug 
    opened by yurivict 10
  • Logging Interrupting Progress Bar

    Logging Interrupting Progress Bar

    Describe the bug When using enlighten and logging, the progress bar is being interrupted everytime I log.

    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    Backtesting  18%|█████████████████████▊                                                                                                   |  9/50 [00:00<00:01, 81.32 bars/s]INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    INFO:__main__:LOG
    Backtesting  36%|███████████████████████████████████████████▌                                                                             | 18/50 [00:00<00:00, 81.41 bars/s]INFO:__main__:LOG
    

    To Reproduce

    import logging
    import time
    
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger(__name__)
    
    my_list = list(range(50))
    pbar = enlighten.Counter(total=len(my_list), desc="Backtesting",
                                          unit="bars", color="blue")
    
    for l in my_list:
        time.sleep(.01)
        logger.info("LOG")
        pbar.update()
    

    Environment (please complete the following information):

    • Enlighten Version: 1.11.1
    • OS and version: MacOS M1 Chip
    • Console application: iterm2
    • Special Conditions: Running with poetry in python 3.10.5
    bug 
    opened by ngriffiths13 2
  • Allow Manager instances to be passed between processes

    Allow Manager instances to be passed between processes

    Is your feature request related to a problem? Please describe. I would like a subprocess to be able to update a counter while there are other counters managed by the main process.

    Right now a manager can't be shared because it cannot share the TextIOWrapper that is stdout/stderr, so new managers are writing over eachother.

    Describe the solution you'd like Ideally I'd like to be able to pass an instance of a Manager to a child process and let the child process create and update counters. This probably involves some kind of pickle-specific behavior to ensure the main processes' output streams aren't attempted to be copied.

    Describe alternatives you've considered A less change-heavy alternative could be to add an additional class (maybe ManagerProxy) which could be retrieved from an existing manager (manager.get_proxy()) and this new instance could pickled in order to share it with child processes. The proxy would have the same API, but all output would be sent via a pipe and read by the parent process during an update.

    The proxy approach might not work well if the main process blocks for a long period, but perhaps a process just for directing terminal output could be started.

    Additional context Tried to pass the manager between processes:

    TypeError: cannot pickle '_io.TextIOWrapper' object
    

    Originally I was using tqdm, which did work between processes but every progress bar had to be positioned manually and they would interfere if processes updated the bars at the same time.

    Feature Request 
    opened by robobenklein 5
  • Tracking PyCharm/IntelliJ/CLion CSR issue

    Tracking PyCharm/IntelliJ/CLion CSR issue

    Describe the bug enlighten doesn't seem to support "Terminal" in JetBrain's IDEs

    To Reproduce Run demo.py in the "Terminal" tab in PyCharm

    Environment (please complete the following information):

    • Enlighten Version: 1.6.2
    • OS and version: MacOS 10.15.7
    • Console application: PyCharm 2020.2.3
    • Special Conditions: N/A

    Additional context Maybe I'm missing something? A brand new PyCharm install, and using the normal Terminal tab Screen Shot 2020-10-08 at 11 43 51 AM

    Not a Bug 
    opened by dominick-han 5
Releases(1.11.1)
  • 1.11.1(Oct 10, 2022)

    Bugfixes

    • Wrong stream referenced in tests
    • Multiple bug fixes for utility classes used by NotebookManager
      • HTMLConverter: Don't test blink if not listed as supported on platform
      • HTMLConverter: Did not handle when term.normal was a single termcap
      • HTMLConverter: Friendly color names depended on the platform
        • Now friendly color names are always used for class names when available
      • HTMLConverter: Tests attempted to use a different term kind than other tests
      • Lookahead raised exception when iterator was empty

    Changes

    • HTMLConverter: Termcap parsing is now cached to improve performance for multiple lookups.
    Source code(tar.gz)
    Source code(zip)
  • 1.11.0(Sep 29, 2022)

    Changes

    • Default to sys.__stdout__ instead of sys.stdout
      • For most this will be a no-op change since sys.stdout, by default, references sys.__stdout__
      • Should increase compatibility on platforms where stdout has been redirected such as #49

    Housekeeping

    • Code tweaks and linting fixes
    Source code(tar.gz)
    Source code(zip)
  • 1.10.2(Dec 12, 2021)

    Changes

    • Curly braces in field names no longer have to be escaped #45

    Bugfixes

    • Bytecode for examples and tests no longer included in sdist
    • companion_stream tests did not provide coverage in some test environments
    • TestManager.test_autorefresh failed on macOS #44

    Housekeeping

    • Switched to GitHub Actions for testing
    • Fixes for Pylint changes
    Source code(tar.gz)
    Source code(zip)
  • 1.10.1(May 14, 2021)

    Bugfixes

    • Jupyter output order reversed
    • Special characters in Jupyter output not escaped
    • Demo example imports break depending on how it's called
    • Whitespace missing on PyPI readme
    Source code(tar.gz)
    Source code(zip)
  • 1.10.0(May 13, 2021)

  • 1.9.0(Mar 28, 2021)

    New Features

    • Human-readable numeric prefixes #29
      • Allows automatic conversion of SI (metric) and IEC (binary) unit prefixes
    • Improved exemption messages for unavailable reserve fields
    • rate_0, rate_00, interval_0, and interval_00 added as formatting fields

    Changes

    • New dependency: Prefixed
    • all_fields can now be specified as a keyword argument to Counter to set the default value for subcounters

    Housekeeping

    • Minor refactoring and optimizations
    • Demo updated
    • Added Conda badge and instructions
    Source code(tar.gz)
    Source code(zip)
  • 1.8.0(Feb 23, 2021)

    New Features

    • Manager.counter() and Manager.status_bar() now have a replace keyword argument

      • replace value must be an existing managed counter or status bar
      • New counter will assume the position of the counter it replaces
      • Old counter will be closed and removed
      • Equivalent to setting leave=False and running counter.close before adding a new counter
    • percentage_00 and count_00 added as bar_format formatting fields (#42)

      • Sum of percentages and counts for all subcounters
      • Inverse of percentage_0 and count_0

    Changes

    Bugfixes

    • Improved behavior of multicolored bars to avoid partial bars when count is 0 (#41)

    Housekeeping

    • Fixed typos
    • Minor refactoring
    Source code(tar.gz)
    Source code(zip)
  • 1.7.2(Dec 26, 2020)

    Changes

    • Manager() argument, threaded, now defaults to True when multiple processes are detected
    • Evaluation of Manager() argument, threaded, now deferred until scroll area is set when not set explicitly
    • Added FAQ question about reentrant calls

    Housekeeping

    • blessed.Terminal subclass removed
    • Removed assert statements from code
    Source code(tar.gz)
    Source code(zip)
  • 1.7.1(Dec 22, 2020)

  • 1.7.0(Nov 30, 2020)

    New Features

    • Added interval, the inverse of rate as a built-in formatting field. [ Issue #34 ]
    • Added new Manager() argument, threaded, which forces threading behavior when True
      • Defaults to True when multiple threads are detected

    Changes

    • Deferred resize handing introduced in 1.6.2 is now only performed if threaded is True (default when multiple threads are detected)

    Bugfixes

    • Improved resize handing [ Issue #33 ]

    Housekeeping

    • Add 3.9 support to package metadata
    • Minor optimizations
    Source code(tar.gz)
    Source code(zip)
  • 1.6.2(Aug 25, 2020)

    Changes

    • Output will now be resized on the first write after a resize is detected
      • This addresses an issue that can cause threaded programs to crash #28
    • Default Unicode are now used when running under Windows Terminal
      • Other windows terminals, like CMD, will still default to cp65001 compatible characters

    Bug fixes'

    • Additional stream flushes added to ensure incidental flush aren't relied upon #21
    • Updated RPM installation instructions
    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Jul 29, 2020)

    Changes

    • Warning is now emitted when a reserved field is passed as a user-defined field
    • Drop Python 2.6 support
    • Begin testing 3.10-dev

    Bug fixes

    • Preserve max scroll offset when number of status bars decrease (#27)
    • Minor doc fixes
    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Jun 19, 2020)

    New Features

    • Status bars can now be created with Manager.status_bar()
    • Bars can now be invoked with autorefresh=True to trigger a refresh whenever another bar is updated or refreshed
    • fill can now be used multiple times in counters and status bars
      • Remaining space is divided equally
    • Fill character can now be specified for counters, with fill keyword
    • Compound colors, like 'aqua_on_seagreen' are now supported
    • Additional keywords passed to Counter() and Counter.update() are now used as user-defined fields

    Changes

    Bug fixes

    • Position pinning now works as expected
    Source code(tar.gz)
    Source code(zip)
  • 1.5.2(May 23, 2020)

  • 1.5.1(Mar 29, 2020)

    Bug Fixes:

    • Fix Read The Docs references that point to latest
    • Support counter tests in non-Unicode environments
    • Account for unsupported encoding value when determining default series
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Mar 23, 2020)

    New Features:

    • Support for RGB and X11 colors
    • New parameter for Counter(): additional_fields
      • User-defined fields available for counter formatting
    • New multiprocessing example
    • Subcounter fields count_n and rate_n are now available in counter-only format
    • New repr output

    Bug Fixes:

    • Fallback series for non-unicode encoding #13
    • Workaround implemented for Python 3.9 Issue 39966

    Changes:

    • Drop EL6-specific testing
      • Python 2.6 automated testing is still enabled, but failures are non-blocking
    • Specifying color by index is now deprecated
    • Minimum supported version of Blessed is 1.17.2

    Housekeeping:

    • Added Python 3.9-dev testing
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Oct 26, 2019)

    New Features:

    • Escape sequences automatically detected when determining bar width When offset is set, this functionality is disabled

    Changes:

    • Flush streams on program exit Prevents escape processing from being disabled on Windows before all data with written to the terminal
    • Use Blessed for Windows support Windows support in Enlighten has been merged into Blessed

    Housekeeping:

    • Update FAQ
    • Cleanup Examples
    • Unicode cleanup (Python 2.7)
    • Add tests and metadata for Python 3.8 Final
    Source code(tar.gz)
    Source code(zip)
  • 1.3.3(Oct 1, 2019)

  • 1.3.2(Oct 1, 2019)

  • 1.3.1(Sep 30, 2019)

    • Bugfix: Account for stream without encoding attribute
    • Add PEP 508 dependency logic
    • Manager logic when using Counter directly now uses get_manager()
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Apr 15, 2019)

  • 1.2.0(Mar 30, 2019)

  • 1.1.0(Dec 17, 2018)

  • 1.0.7(Nov 28, 2017)

  • 1.0.6(Oct 14, 2017)

Owner
Rockhopper Technologies
Linux and Open Source Consulting
Rockhopper Technologies
Doing set operations on files considered as sets of lines

CLI tool that can be used to do set operations like union on files considering them as a set of lines. Notes It ignores all empty lines with whitespac

Partho 11 Sep 06, 2022
An anime command-line system information tool written in python.

Animefetch - v0.0.3 An anime command-line system information tool written in python. Description Animefetch is an anime command-line system informatio

Thadeuks 6 Jun 17, 2022
Bringing emacs' greatest feature to neovim - Tetris!

nvim-tetris Bringing emacs' greatest feature to neovim - Tetris! This plugin is written in Fennel using Olical's project Aniseed for creating the proj

129 Dec 26, 2022
A simple Python CLI tool that draws routes/paths on a given map.

Map Router A simple Python CLI tool that draws routes/paths on a given map. Index Installation Usage Docs Why? License Support Installation Coming soo

Pedro Morim 1 Nov 07, 2021
pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo

pyGinit pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo Requirements Requirements be

AlphaBeta 15 Feb 26, 2022
A python command line tool to calculate options max pain for a given company symbol and options expiry date.

Options-Max-Pain-Calculator A python command line tool to calculate options max pain for a given company symbol and options expiry date. Overview - Ma

13 Dec 26, 2022
Command line util for grep.app - Search across a half million git repos

grepgithub Command line util for grep.app - Search across a half million git repos Grepgithub uses grep.app API to search GitHub repositories, providi

Nenad Popovic 18 Dec 28, 2022
Magnificent app which corrects your previous console command.

The Fuck The Fuck is a magnificent app, inspired by a @liamosaur tweet, that corrects errors in previous console commands. Is The Fuck too slow? Try t

Vladimir Iakovlev 75k Jan 02, 2023
Simple Terminal Styling for Python

escape Escape is a very simple terminal styling library largely inspired by the excellent javascript chalk library. There are other terminal styling l

Syed Abbas 8 Sep 03, 2019
This a simple tool to query the awesome ippsec.rocks website from your terminal

ippsec-cli This a simple tool to query the awesome ippsec.rocks website from your terminal Installation and usage cd /opt git clone https://github.com

stark0de 5 Nov 26, 2022
Squirrel - A cli program to track writing progress

Squirrel Very much a WIP project squirrel is a command line program that tracks you writing progress and gives you useful information and cute and pic

3 Mar 23, 2022
Color preview command-line tool written in python

Color preview command-line tool written in python

Arnau 1 Dec 27, 2021
CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that data.

CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that

Peter Baumgartner 29 Aug 09, 2022
jrnl is a simple journal application for the command line.

jrnl To get help, submit an issue on Github. jrnl is a simple journal application for the command line. You can use it to easily create, search, and v

jrnl 5.7k Dec 31, 2022
A stupidly simple task list to keep you productive and focused.

StupidlySimple-TaskList A stupidly simple task list to keep you productive and focused. There is really nothing to it. This is a terminal-based script

Jack Soderstrom 1 Nov 28, 2021
organize your books on the command line

organize your books on the command line

Ben Winston 19 Jan 21, 2022
ghfetch is ai customizable CLI GitHub personal README generator.

ghfetch is ai customizable CLI GitHub personal README generator. Inspired by famous fetch such as screenfetch, neofetch and ufetch, the purpose of this tool is to introduce yourself as if you were a

Alessio Celentano 3 Sep 10, 2021
This is a CLI program which can help you generate your own QR Code.

Python-QR-code-generator This is a CLI program which can help you generate your own QR Code. Single.py This will allow you only to input a single mess

1 Dec 24, 2021
CLI Web-CAT interface for people who use VIM.

CLI Web-CAT CLI Web-CAT interface. Installation git clone https://github.com/phuang1024/cliwebcat cd cliwebcat python setup.py bdist_wheel sdist cd di

Patrick 4 Apr 11, 2022
A tool to automatically convert old string literal formatting to f-strings

flynt - string formatting converter flynt is a command line tool to automatically convert a project's Python code from old "%-formatted" and .format(.

Elijah K 551 Jan 06, 2023