* start implementing progress stuff in CLI
This commit is contained in:
+21
@@ -12,6 +12,13 @@ class CLI:
|
|||||||
def __init__(self, debuggy = True):
|
def __init__(self, debuggy = True):
|
||||||
self.showDebug = debuggy
|
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):
|
def info(self, msg):
|
||||||
sys.stdout.write(colorize(msg, 'blue'))
|
sys.stdout.write(colorize(msg, 'blue'))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
@@ -25,6 +32,20 @@ class CLI:
|
|||||||
sys.stdout.write(colorize(msg, 'red'))
|
sys.stdout.write(colorize(msg, 'red'))
|
||||||
sys.stdout.flush()
|
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
|
# default UI is CLI
|
||||||
ui = CLI()
|
ui = CLI()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user