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
1d329d27
Commit
1d329d27
authored
Dec 05, 2012
by
Stavros Sachtouris
Browse files
Better pithos upload progressbar
parent
5f7882af
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/argument.py
View file @
1d329d27
...
...
@@ -38,7 +38,8 @@ from kamaki.cli.utils import split_input
from
argparse
import
ArgumentParser
,
ArgumentError
try
:
from
progress.bar
import
IncrementalBar
from
progress.bar
import
FillingCirclesBar
as
KamakiProgressBar
# IncrementalBar
except
ImportError
:
# progress not installed - pls, pip install progress
pass
...
...
@@ -285,7 +286,7 @@ class ProgressBarArgument(FlagArgument):
self
.
suffix
=
'%(percent)d%%'
super
(
ProgressBarArgument
,
self
).
__init__
(
help
,
parsed_name
,
default
)
try
:
Incremental
Bar
KamakiProgress
Bar
except
NameError
:
print
(
'Warning: no progress bar functionality'
)
...
...
@@ -303,7 +304,7 @@ class ProgressBarArgument(FlagArgument):
if
self
.
value
:
return
None
try
:
self
.
bar
=
Incremental
Bar
()
self
.
bar
=
KamakiProgress
Bar
()
except
NameError
:
self
.
value
=
None
return
self
.
value
...
...
kamaki/clients/pithos.py
View file @
1d329d27
...
...
@@ -172,9 +172,11 @@ class PithosClient(PithosRestAPI):
r
.
release
()
# upload_* auxiliary methods
def
_put_block_async
(
self
,
data
,
hash
):
def
_put_block_async
(
self
,
data
,
hash
,
upload_gen
=
None
):
event
=
SilentEvent
(
method
=
self
.
_put_block
,
data
=
data
,
hash
=
hash
)
event
.
start
()
if
upload_gen
:
upload_gen
.
next
()
return
event
def
_put_block
(
self
,
data
,
hash
):
...
...
@@ -251,6 +253,8 @@ class PithosClient(PithosRestAPI):
if
upload_cb
:
upload_gen
=
upload_cb
(
len
(
missing
))
upload_gen
.
next
()
else
:
upload_gen
=
None
self
.
_init_thread_limit
()
...
...
@@ -259,7 +263,7 @@ class PithosClient(PithosRestAPI):
offset
,
bytes
=
hmap
[
hash
]
fileobj
.
seek
(
offset
)
data
=
fileobj
.
read
(
bytes
)
r
=
self
.
_put_block_async
(
data
,
hash
)
r
=
self
.
_put_block_async
(
data
,
hash
,
upload_gen
)
flying
.
append
(
r
)
unfinished
=
[]
for
i
,
thread
in
enumerate
(
flying
):
...
...
@@ -268,13 +272,14 @@ class PithosClient(PithosRestAPI):
if
thread
.
isAlive
()
or
thread
.
exception
:
unfinished
.
append
(
thread
)
else
:
if
upload_cb
:
upload_gen
.
next
()
#
else:
#
if upload_cb:
#
upload_gen.next()
flying
=
unfinished
for
thread
in
flying
:
thread
.
join
()
#upload_gen.next()
failures
=
[
r
for
r
in
flying
if
r
.
exception
]
if
len
(
failures
):
...
...
@@ -284,12 +289,6 @@ class PithosClient(PithosRestAPI):
status
=
505
,
details
=
details
)
while
upload_cb
:
try
:
upload_gen
.
next
()
except
StopIteration
:
break
def
upload_object
(
self
,
obj
,
f
,
size
=
None
,
hash_cb
=
None
,
...
...
@@ -350,6 +349,7 @@ class PithosClient(PithosRestAPI):
if
missing
is
None
:
return
try
:
self
.
_upload_missing_blocks
(
missing
,
hmap
,
f
,
upload_cb
=
upload_cb
)
except
KeyboardInterrupt
:
...
...
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