This repository has been archived on 2023-02-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-benchmark-bundle/benchmark/foundation/progress.py

35 lines
813 B
Python
Raw Normal View History

2017-08-18 12:12:25 +02:00
import shutil
import sys
from foundation import logger
def progress(count, total, prefix="", suffix=""):
if logger.VERBOSE:
return
size = shutil.get_terminal_size((80, 20))
if prefix != "":
prefix = prefix + " "
if suffix != "":
suffix = " " + suffix
bar_len = size.columns - len(prefix) - len(suffix) - 10
filled_len = int(round(bar_len * count / float(total)))
percents = round(100.0 * count / float(total), 1)
bar = '=' * filled_len + '-' * (bar_len - filled_len)
sys.stdout.write('%s[%s] %s%%%s\r' % (prefix, bar, percents, suffix))
sys.stdout.flush()
def progressClear():
if logger.VERBOSE:
return
size = shutil.get_terminal_size((80, 20))
sys.stdout.write(" " * size.columns + "\r")
sys.stdout.flush()