Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
863dd770
Commit
863dd770
authored
Apr 23, 2012
by
Giorgos Verigakis
Browse files
Switch to progress for progress bars
parent
098ca087
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli.py
View file @
863dd770
...
...
@@ -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
...
...
setup.py
View file @
863dd770
...
...
@@ -52,6 +52,7 @@ setup(
},
install_requires
=
[
'ansicolors>=1.0'
,
'progress>=1.0'
,
'requests>=0.11'
,
'clint>=0.3'
,
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment