From 4ef14fb3457466f3a33e8f0c13d6ee819de982a8 Mon Sep 17 00:00:00 2001 From: Giorgos Verigakis Date: Mon, 23 Apr 2012 15:21:19 +0300 Subject: [PATCH] Switch to progress for progress bars --- kamaki/cli.py | 11 ++++++----- setup.py | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/kamaki/cli.py b/kamaki/cli.py index 4aaf09b..19d41f6 100755 --- a/kamaki/cli.py +++ b/kamaki/cli.py @@ -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 diff --git a/setup.py b/setup.py index 2bbfcd2..4a4ec83 100755 --- 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', ] -- 1.7.10.4