Package: etaprogress
Draw progress bars with room for colors and display rates and ETAs in your console applications. ETA library is its own
class so it may be used in other non-console applications. ETAs calculated with simple linear regression.This library supports both defined and undefined progress bars. Undefined progress bars are those that do not have a
“total size”. Similar to when wget downloads a file with an unknown file size. Due to this, undefined progress bars
have no percent and no ETA. Defined progress bars are the usual progress bars with percentages and ETAs.Python 2.6, 2.7, 3.3, and 3.4 supported on Linux and OS X.Python 2.7, 3.3, and 3.4 supported on Windows (both 32 and 64 bit versions of Python).Tested on Windows XP and Windows 10 technical preview.QuickstartInstall:pipinstalletaprogressExample ImplementationsSource code for examples:example.py,example_colors.py,
andexample_wget.pyUsageIf all you need is a progress bar with an ETA, you only have to import a class in theetaprogress.progressmodule.
To get the progress bar itself just cast to string or print the instance.Simple Usageimporttimefrometaprogress.progressimportProgressBartotal=5bar=ProgressBar(total,max_width=40)foriinrange(total+1):bar.numerator=iprintbartime.sleep(1)0% (0/5) [               ] eta --:-- -
 20% (1/5) [###            ] eta 00:05 \
 40% (2/5) [######         ] eta 00:04 |
 60% (3/5) [#########      ] eta 00:03 /
 80% (4/5) [############   ] eta 00:02 -
100% (5/5) [###############] eta 00:00 \Of course that’s not a very good progress bar animation. Here’s a better one withprint_function:from__future__importprint_functionimportsysimporttimefrometaprogress.progressimportProgressBartotal=5bar=ProgressBar(total,max_width=40)foriinrange(total+1):bar.numerator=iprint(bar,end='\r')sys.stdout.flush()time.sleep(1)print()100% (5/5) [###############] eta 00:00 \Terminal Colors SupportColors are supported usingcolorclass. Take a look atexample_colors.pyon how to implement
colorful progress bars. You may have to subclass one of the ProgressBar classes (or even BaseProgressBar) to add colors
to every nook and cranny of a progress bar.Class AttributesThere are five different progress bar classes with visual differences:ProgressBar– a simple progress bar.ProgressBarBits– similar toProgressBarbut converts numbers to bits, kilobits, etc.ProgressBarBytes– similar toProgressBarbut converts numbers to bytes, kibibytes (kilobytes), etc.ProgressBarWget– a progress bar that looks like the one in the GNUwgetapplication.ProgressBarYum– a progress bar that looks like the one in CentOS/RHEL 7yumutility.NameDescription/Notesmax_widthLimit number of characters shown (by default the full progress bar takes up the entire terminal width).eta_everyCalculate and cache the ETA string after this many numerator setting iteration. Default is every iter.force_doneFor undefined progress bars this indicates that the progress has completed.filename‘ProgressBarYum’ only. The string to display before the progress bar. Limited to whatever space is available in the terminal.Class PropertiesNameDescription/NotesdenominatorReturns the denominator of the progress bars. The same value provided when instantiating.doneReturns True if the progress has completed.numeratorRead/write. Returns the numerator as an integer or sets a new numerator. When setting a numerator it must be equal to or greater than the previous one.percentReturns the percent as a float.rateReturns the rate of the progress as a float.undefinedReturn True if the progress bar is undefined.Changelog1.1.1Fixed broken setup.py file.1.1.0Added Windows support.1.0.0Initial release.