Revision 4ef14fb3
b/kamaki/cli.py | ||
---|---|---|
80 | 80 |
from sys import argv, exit, stdout, stderr |
81 | 81 |
|
82 | 82 |
from clint import args |
83 |
from clint.textui import progress |
|
84 | 83 |
from colors import magenta, red, yellow |
84 |
from progress.bar import IncrementalBar |
|
85 | 85 |
from requests.exceptions import ConnectionError |
86 | 86 |
|
87 | 87 |
from kamaki import clients |
... | ... | |
102 | 102 |
'astakos': "Astakos API commands"} |
103 | 103 |
|
104 | 104 |
|
105 |
class ProgressBar(IncrementalBar): |
|
106 |
suffix = '%(percent)d%% - %(eta)ds' |
|
107 |
|
|
108 |
|
|
105 | 109 |
def command(api=None, group=None, name=None, syntax=None): |
106 | 110 |
"""Class decorator that registers a class as a CLI command.""" |
107 | 111 |
|
... | ... | |
669 | 673 |
"""Return a generator function to be used for progress tracking""" |
670 | 674 |
|
671 | 675 |
MESSAGE_LENGTH = 25 |
672 |
MAX_PROGRESS_LENGTH = 32 |
|
673 | 676 |
|
674 | 677 |
def progress_gen(n): |
675 | 678 |
msg = message.ljust(MESSAGE_LENGTH) |
676 |
width = min(n, MAX_PROGRESS_LENGTH) |
|
677 |
hide = self.config.get('global', 'silent') or (n < 2) |
|
678 |
for i in progress.bar(range(n), msg, width, hide): |
|
679 |
for i in ProgressBar(msg).iter(range(n)): |
|
679 | 680 |
yield |
680 | 681 |
yield |
681 | 682 |
|
b/setup.py | ||
---|---|---|
52 | 52 |
}, |
53 | 53 |
install_requires=[ |
54 | 54 |
'ansicolors>=1.0', |
55 |
'progress>=1.0', |
|
55 | 56 |
'requests>=0.11', |
56 | 57 |
'clint>=0.3', |
57 | 58 |
] |
Also available in: Unified diff