c521b8c28c
use absolute path imports to compat python3 remove H301 ignore to enable H304 flake8 check Story: 2003433 Task: 28376 Change-Id: I3a50a0298fe34c60e3c63df23e72dcbb07c585d1 Signed-off-by: Sun Austin <austin.sun@intel.com>
32 lines
840 B
Python
32 lines
840 B
Python
import sys
|
|
|
|
from controllerconfig.common import log
|
|
|
|
LOG = log.get_logger(__name__)
|
|
|
|
|
|
class ProgressRunner(object):
|
|
steps = []
|
|
|
|
def add(self, action, message):
|
|
self.steps.append((action, message))
|
|
|
|
def run(self):
|
|
total = len(self.steps)
|
|
for i, step in enumerate(self.steps, start=1):
|
|
action, message = step
|
|
LOG.info("Start step: %s" % message)
|
|
sys.stdout.write(
|
|
"\n%.2u/%.2u: %s ... " % (i, total, message))
|
|
sys.stdout.flush()
|
|
try:
|
|
action()
|
|
sys.stdout.write('DONE')
|
|
sys.stdout.flush()
|
|
except Exception:
|
|
sys.stdout.flush()
|
|
raise
|
|
LOG.info("Finish step: %s" % message)
|
|
sys.stdout.write("\n")
|
|
sys.stdout.flush()
|