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
55c75058
Commit
55c75058
authored
May 17, 2013
by
Stavros Sachtouris
Browse files
Add output to file copy/move
Also, kamaki.clients.pithos.copy/move_object returns response headers Refs: #3756 #3732
parent
94bedc5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Changelog
View file @
55c75058
...
...
@@ -18,6 +18,8 @@ Changes:
- Disallow moving deleted objects by version [#3737]
This operation was implemented by accident, due to the symetry between
move and copy
- Add optional output for file methods [#3756, #3732]:
mkdir, touch, create, move, create, copy, move
Features:
...
...
@@ -35,6 +37,4 @@ Features:
- Add a download_to_string method in pithos client [#3608]
- Add an upload_from_string method in pithos client [#3608]
- Add pithos client method create_container [#3756]
- Add output for file methods [#3756, #3732]:
mkdir, touch, create
kamaki/cli/commands/pithos.py
View file @
55c75058
...
...
@@ -727,7 +727,9 @@ class file_copy(_source_destination_command):
default
=
''
),
source_version
=
ValueArgument
(
'copy specific version'
,
(
'-S'
,
'--source-version'
))
(
'-S'
,
'--source-version'
)),
with_output
=
FlagArgument
(
'show request headers'
,
(
'--with-output'
)),
json_output
=
FlagArgument
(
'show headers in json'
,
(
'-j'
,
'--json'
))
)
@
errors
.
generic
.
all
...
...
@@ -741,7 +743,7 @@ class file_copy(_source_destination_command):
for
src_obj
,
dst_obj
in
self
.
src_dst_pairs
(
dst_path
,
self
[
'source_version'
]):
no_source_object
=
False
self
.
dst_client
.
copy_object
(
r
=
self
.
dst_client
.
copy_object
(
src_container
=
self
.
client
.
container
,
src_object
=
src_obj
,
dst_container
=
self
.
dst_client
.
container
,
...
...
@@ -754,6 +756,11 @@ class file_copy(_source_destination_command):
raiseCLIError
(
'No object %s in container %s'
%
(
self
.
path
,
self
.
container
))
if
self
[
'json_output'
]:
print_json
(
r
)
elif
self
[
'with_output'
]:
print_dict
(
r
)
def
main
(
self
,
source_container___path
,
...
...
@@ -815,7 +822,9 @@ class file_move(_source_destination_command):
suffix_replace
=
ValueArgument
(
'Suffix of src to replace with add_suffix, if matched'
,
'--suffix-to-replace'
,
default
=
''
)
default
=
''
),
with_output
=
FlagArgument
(
'show request headers'
,
(
'--with-output'
)),
json_output
=
FlagArgument
(
'show headers in json'
,
(
'-j'
,
'--json'
))
)
@
errors
.
generic
.
all
...
...
@@ -827,19 +836,22 @@ class file_move(_source_destination_command):
self
[
'destination_account'
])
else
None
for
src_obj
,
dst_obj
in
self
.
src_dst_pairs
(
dst_path
):
no_source_object
=
False
self
.
dst_client
.
move_object
(
r
=
self
.
dst_client
.
move_object
(
src_container
=
self
.
container
,
src_object
=
src_obj
,
dst_container
=
self
.
dst_client
.
container
,
dst_object
=
dst_obj
,
source_account
=
src_account
,
source_version
=
self
[
'source_version'
],
public
=
self
[
'public'
],
content_type
=
self
[
'content_type'
])
if
no_source_object
:
raiseCLIError
(
'No object %s in container %s'
%
(
self
.
path
,
self
.
container
))
if
self
[
'json_output'
]:
print_json
(
r
)
elif
self
[
'with_output'
]:
print_dict
(
r
)
def
main
(
self
,
source_container___path
,
...
...
kamaki/clients/pithos/__init__.py
View file @
55c75058
...
...
@@ -1363,11 +1363,13 @@ class PithosClient(PithosRestClient):
:param content_type: (str)
:param delimiter: (str)
:returns: (dict) response headers
"""
self
.
_assert_account
()
self
.
container
=
dst_container
src_path
=
path4url
(
src_container
,
src_object
)
self
.
object_put
(
r
=
self
.
object_put
(
dst_object
or
src_object
,
success
=
201
,
copy_from
=
src_path
,
...
...
@@ -1377,6 +1379,7 @@ class PithosClient(PithosRestClient):
public
=
public
,
content_type
=
content_type
,
delimiter
=
delimiter
)
return
r
.
headers
def
move_object
(
self
,
src_container
,
src_object
,
dst_container
,
...
...
@@ -1404,12 +1407,14 @@ class PithosClient(PithosRestClient):
:param content_type: (str)
:param delimiter: (str)
:returns: (dict) response headers
"""
self
.
_assert_account
()
self
.
container
=
dst_container
dst_object
=
dst_object
or
src_object
src_path
=
path4url
(
src_container
,
src_object
)
self
.
object_put
(
r
=
self
.
object_put
(
dst_object
,
success
=
201
,
move_from
=
src_path
,
...
...
@@ -1419,6 +1424,7 @@ class PithosClient(PithosRestClient):
public
=
public
,
content_type
=
content_type
,
delimiter
=
delimiter
)
return
r
.
headers
def
get_sharing_accounts
(
self
,
limit
=
None
,
marker
=
None
,
*
args
,
**
kwargs
):
"""Get accounts that share with self.account
...
...
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