summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2016-05-05 16:49:24 +0200
committerMartin Basti <mbasti@redhat.com>2016-05-10 12:41:15 +0200
commit5dbb0f6fec59defd795dd501b67740a79616e86b (patch)
tree4bd8fb0f4119a89ddf36caa4312032bb9b708abb /ipalib/cli.py
parenta9a13530988c616b331545ea02f539d39df64e27 (diff)
downloadfreeipa-5dbb0f6fec59defd795dd501b67740a79616e86b.tar.gz
freeipa-5dbb0f6fec59defd795dd501b67740a79616e86b.tar.xz
freeipa-5dbb0f6fec59defd795dd501b67740a79616e86b.zip
ipalib.cli: Improve reporting of binary values in the CLI
Make sure the base64-encoded value is a string, so it is printed without the b'' markers. Part of the work for: https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 3592d3b61..3692e4e53 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -164,10 +164,11 @@ class textui(backend.Backend):
def encode_binary(self, value):
"""
Convert a binary value to base64. We know a value is binary
- if it is a python str type, otherwise it is a plain string.
+ if it is a python bytes type, otherwise it is a plain string.
+ This function also converts datetime and DNSName values to string.
"""
if type(value) is bytes:
- return base64.b64encode(value)
+ return base64.b64encode(value).decode('ascii')
elif type(value) is datetime.datetime:
return value.strftime(LDAP_GENERALIZED_TIME_FORMAT)
elif isinstance(value, DNSName):