Commit d3650a58 authored by payno's avatar payno

[core][progress] rework the text advancement

parent 13f717a6
......@@ -62,7 +62,7 @@ class _Advancement(Enum):
else:
return _Advancement.step_1
import sys
class Progress(object):
"""Simple interface for defining advancement on a 100 percentage base"""
def __init__(self, name):
......@@ -74,13 +74,19 @@ class Progress(object):
self._maxProcessed = max_
def startProcess(self):
_logger.info('start process' + self._name)
self.setAdvancement(0)
def setAdvancement(self, value):
_logger.info(_Advancement.getStep(value))
length = 20 # modify this to change the length
block = int(round(length * value/100))
msg = "\r{0}: [{1}] {2}%".format(self._name, "#" * block + "-" * (length - block), round(value, 2))
if value >= 100:
msg += " DONE\r\n"
sys.stdout.write(msg)
sys.stdout.flush()
def endProcess(self):
_logger.info('process finished' + self._name)
self.setAdvancement(100)
def setMaxSpectrum(self, n):
self._maxProcessed = n
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment