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
81e34150
Commit
81e34150
authored
Jan 15, 2013
by
Stavros Sachtouris
Browse files
Merge branch 'feature-output' into develop
Conflicts: kamaki/clients/__init__.py kamaki/clients/pithos.py
parents
16c895db
706fc940
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/commands/pithos_cli.py
View file @
81e34150
...
...
@@ -873,9 +873,27 @@ class store_upload(_store_container_command):
progress_bar
=
ProgressBarArgument
(
'do not show progress bar'
,
'--no-progress-bar'
,
default
=
False
)
default
=
False
),
overwrite
=
FlagArgument
(
'Force overwrite, if object exists'
,
'-f'
)
)
def
_remote_path
(
self
,
remote_path
,
local_path
=
''
):
if
self
[
'overwrite'
]:
return
remote_path
try
:
r
=
self
.
client
.
get_object_info
(
remote_path
)
except
ClientError
as
ce
:
if
ce
.
status
==
404
:
return
remote_path
ctype
=
r
.
get
(
'content-type'
,
''
)
if
'application/directory'
==
ctype
.
lower
():
ret
=
'%s/%s'
%
(
remote_path
,
local_path
)
return
self
.
_remote_path
(
ret
)
if
local_path
else
ret
raiseCLIError
(
'Object %s already exists'
%
remote_path
,
importance
=
1
,
details
=
[
'use -f to overwrite'
])
def
main
(
self
,
local_path
,
container____path__
):
super
(
self
.
__class__
,
self
).
main
(
container____path__
)
remote_path
=
self
.
path
if
self
.
path
else
local_path
...
...
@@ -889,6 +907,7 @@ class store_upload(_store_container_command):
sharing
=
self
[
'sharing'
],
public
=
self
[
'public'
])
try
:
remote_path
=
self
.
_remote_path
(
remote_path
,
local_path
)
progress_bar
=
self
.
arguments
[
'progress_bar'
]
hash_bar
=
progress_bar
.
clone
()
with
open
(
path
.
abspath
(
local_path
),
'rb'
)
as
f
:
...
...
@@ -912,8 +931,11 @@ class store_upload(_store_container_command):
progress_bar
.
finish
()
hash_bar
.
finish
()
except
ClientError
as
err
:
progress_bar
.
finish
()
hash_bar
.
finish
()
try
:
progress_bar
.
finish
()
hash_bar
.
finish
()
except
Exception
:
pass
if
err
.
status
==
404
:
if
'container'
in
(
'%s'
%
err
).
lower
():
raiseCLIError
(
...
...
@@ -929,10 +951,18 @@ class store_upload(_store_container_command):
raise_connection_errors
(
err
)
raiseCLIError
(
err
,
'"%s" not accessible'
%
container____path__
)
except
IOError
as
err
:
progress_bar
.
finish
()
hash_bar
.
finish
()
try
:
progress_bar
.
finish
()
hash_bar
.
finish
()
except
Exception
:
pass
raiseCLIError
(
err
,
'Failed to read form file %s'
%
local_path
,
2
)
except
Exception
as
e
:
try
:
progress_bar
.
finish
()
hash_bar
.
finish
()
except
Exception
:
pass
raiseCLIError
(
e
)
print
'Upload completed'
...
...
kamaki/clients/pithos.py
View file @
81e34150
...
...
@@ -249,8 +249,6 @@ class PithosClient(PithosRestAPI):
if
hash_cb
:
hash_gen
.
next
()
if
offset
!=
size
:
#print("Size is %i" % size)
#print("Offset is %i" % offset)
assert
offset
==
size
,
\
"Failed to calculate uploaded blocks: "
\
"Offset and object size do not match"
...
...
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