Switch to progress for progress bars
authorGiorgos Verigakis <verigak@gmail.com>
Mon, 23 Apr 2012 12:21:19 +0000 (15:21 +0300)
committerGiorgos Verigakis <verigak@gmail.com>
Wed, 9 May 2012 10:18:50 +0000 (13:18 +0300)
kamaki/cli.py
setup.py

index 4aaf09b..19d41f6 100755 (executable)
@@ -80,8 +80,8 @@ from pwd import getpwuid
 from sys import argv, exit, stdout, stderr
 
 from clint import args
-from clint.textui import progress
 from colors import magenta, red, yellow
+from progress.bar import IncrementalBar
 from requests.exceptions import ConnectionError
 
 from kamaki import clients
@@ -102,6 +102,10 @@ GROUPS = {
     'astakos': "Astakos API commands"}
 
 
+class ProgressBar(IncrementalBar):
+    suffix = '%(percent)d%% - %(eta)ds'
+
+
 def command(api=None, group=None, name=None, syntax=None):
     """Class decorator that registers a class as a CLI command."""
     
@@ -669,13 +673,10 @@ class _store_account_command(object):
         """Return a generator function to be used for progress tracking"""
         
         MESSAGE_LENGTH = 25
-        MAX_PROGRESS_LENGTH = 32
         
         def progress_gen(n):
             msg = message.ljust(MESSAGE_LENGTH)
-            width = min(n, MAX_PROGRESS_LENGTH)
-            hide = self.config.get('global', 'silent') or (n < 2)
-            for i in progress.bar(range(n), msg, width, hide):
+            for i in ProgressBar(msg).iter(range(n)):
                 yield
             yield
         
index 2bbfcd2..4a4ec83 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,7 @@ setup(
     },
     install_requires=[
         'ansicolors>=1.0',
+        'progress>=1.0',
         'requests>=0.11',
         'clint>=0.3',
     ]