diff --git a/pisi/ui.py b/pisi/ui.py index 163aae35..a2d3e857 100644 --- a/pisi/ui.py +++ b/pisi/ui.py @@ -12,6 +12,13 @@ class CLI: def __init__(self, debuggy = True): self.showDebug = debuggy + class Progress: + def __init__(self, name, symbol): + self.name = name + self.percent = 0 + self.rate = 0 + self.symbol = symbol + def info(self, msg): sys.stdout.write(colorize(msg, 'blue')) sys.stdout.flush() @@ -25,6 +32,20 @@ class CLI: sys.stdout.write(colorize(msg, 'red')) sys.stdout.flush() + def startProgress(self, name, symbol): + ## support one progress for now + self.activeProgress = Progress(name, symbol) + + def updateProgress(self, percent, rate): + self.activeProgress.percent = percent + self.activeProgress.rate = rate + self.displayProgress(pd) + + def displayProgress(pd): + out = '\r%-30.30s %3d%% %12.2f %s' % \ + (self.name, self.percent, self.rate, self.symbol) + self.info(out) + # default UI is CLI ui = CLI()