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
86a50847
Commit
86a50847
authored
Sep 09, 2013
by
Stavros Sachtouris
Browse files
Expand stream output to pithos print methods
parent
a8262d20
Changes
2
Show whitespace changes
Inline
Side-by-side
kamaki/cli/commands/pithos.py
View file @
86a50847
...
...
@@ -363,9 +363,9 @@ class file_list(_file_container_command, _optional_json, _name_filter):
enum
=
FlagArgument
(
'Enumerate results'
,
'--enumerate'
)
)
def
print_objects
(
self
,
object_list
):
def
print_objects
(
self
,
object_list
,
out
=
stdout
):
if
self
[
'json_output'
]:
print_json
(
object_list
)
print_json
(
object_list
,
out
=
out
)
return
limit
=
int
(
self
[
'limit'
])
if
self
[
'limit'
]
>
0
else
len
(
object_list
)
for
index
,
obj
in
enumerate
(
object_list
):
...
...
@@ -397,9 +397,9 @@ class file_list(_file_container_command, _optional_json, _name_filter):
if
self
[
'more'
]:
page_hold
(
index
,
limit
,
len
(
object_list
))
def
print_containers
(
self
,
container_list
):
def
print_containers
(
self
,
container_list
,
out
=
stdout
):
if
self
[
'json_output'
]:
print_json
(
container_list
)
print_json
(
container_list
,
out
=
out
)
return
limit
=
int
(
self
[
'limit'
])
if
self
[
'limit'
]
>
0
\
else
len
(
container_list
)
...
...
@@ -1615,10 +1615,10 @@ class file_permissions(_pithos_init):
"""
def
print_permissions
(
permissions_dict
):
def
print_permissions
(
permissions_dict
,
out
=
stdout
):
expected_keys
=
(
'read'
,
'write'
)
if
set
(
permissions_dict
).
issubset
(
expected_keys
):
print_dict
(
permissions_dict
)
print_dict
(
permissions_dict
,
out
=
out
)
else
:
invalid_keys
=
set
(
permissions_dict
.
keys
()).
difference
(
expected_keys
)
raiseCLIError
(
...
...
@@ -2071,10 +2071,12 @@ class file_sharers(_file_account_command, _optional_json):
self
.
_run
()
def
version_print
(
versions
):
print_items
([
dict
(
id
=
vitem
[
0
],
created
=
strftime
(
def
version_print
(
versions
,
out
=
stdout
):
print_items
(
[
dict
(
id
=
vitem
[
0
],
created
=
strftime
(
'%d-%m-%Y %H:%M:%S'
,
localtime
(
float
(
vitem
[
1
]))))
for
vitem
in
versions
])
localtime
(
float
(
vitem
[
1
]))))
for
vitem
in
versions
],
out
=
out
)
@
command
(
pithos_cmds
)
...
...
kamaki/clients/__init__.py
View file @
86a50847
...
...
@@ -149,10 +149,8 @@ class RequestManager(Logged):
sendlog
.
info
(
'%s %s://%s%s%s'
%
(
self
.
method
,
self
.
scheme
,
self
.
netloc
,
self
.
path
,
plog
))
for
key
,
val
in
self
.
headers
.
items
():
#if (not self.LOG_TOKEN) and key.lower() == 'x-auth-token':
# continue
show
=
(
key
.
lower
()
!=
'x-auth-token'
)
or
self
.
LOG_TOKEN
sendlog
.
info
(
' %s: %s%s'
%
(
key
,
val
if
show
else
''
,
plog
))
sendlog
.
info
(
' %s: %s%s'
%
(
key
,
val
if
show
else
'
...
'
,
plog
))
if
self
.
data
:
sendlog
.
info
(
'data size:%s%s'
%
(
len
(
self
.
data
),
plog
))
if
self
.
LOG_DATA
:
...
...
@@ -230,12 +228,11 @@ class ResponseManager(Logged):
self
.
status_code
,
self
.
status
,
plog
))
self
.
_headers
=
dict
()
for
k
,
v
in
r
.
getheaders
():
if
(
not
self
.
LOG_TOKEN
)
and
(
k
.
lower
()
==
'x-auth-token'
):
continue
show
=
(
k
.
lower
()
!=
'x-auth-token'
)
or
self
.
LOG_TOKEN
v
=
unquote
(
v
)
self
.
_headers
[
k
]
=
v
recvlog
.
info
(
' %s: %s%s'
%
(
k
,
v
,
plog
))
recvlog
.
info
(
' %s: %s%s'
%
(
k
,
v
if
show
else
'...'
,
plog
))
self
.
_content
=
r
.
read
()
recvlog
.
info
(
'data size: %s%s'
%
(
len
(
self
.
_content
)
if
self
.
_content
else
0
,
plog
))
...
...
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