Commit ae6e15bd authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Fix Python 2.6 compatibility with string "encode"

String method "encode" accepts named arguments only since Python 2.7
parent 2e32d86f
......@@ -16,8 +16,9 @@ Bug fixes
* Set a default logger to LoggedAstakosClient [grnet/kamaki#58]
* Show the correct name when switching kamaki users
[grnet/kamaki#66]
* Fix Python 2.6 compatibility concerning with HTTPS arguments
* Fix Python 2.6 compatibility concerning HTTPS arguments
[grnet/kamaki#73]
* Fix Python 2.6 compatibility concerning encode parameters
v0.13rc4
========
......
......@@ -138,7 +138,7 @@ class CommandInit(object):
@dont_raise(UnicodeError)
def write(self, s):
self._out.write(s.encode(pref_enc, errors='replace'))
self._out.write(s.encode(pref_enc, 'replace'))
self._out.flush()
def writeln(self, s=''):
......@@ -146,7 +146,7 @@ class CommandInit(object):
def error(self, s=''):
esc_s = escape_ctrl_chars(s)
self._err.write(('%s\n' % esc_s).encode(pref_enc, errors='replace'))
self._err.write(('%s\n' % esc_s).encode(pref_enc, 'replace'))
self._err.flush()
def print_list(self, *args, **kwargs):
......
......@@ -80,7 +80,7 @@ def suggest_missing(miss=None, exclude=[]):
if v['active'] and stderr.isatty():
stderr.write('Suggestion: you may like to install %s\n' % k)
stderr.write(
('%s\n' % v['description']).encode(pref_enc, errors='replace'))
('%s\n' % v['description']).encode(pref_enc, 'replace'))
stderr.write('\tIt is easy, here are the instructions:\n')
stderr.write('\t%s/installation.html%s\n' % (
kamaki_docs, v['url']))
......@@ -384,9 +384,9 @@ def ask_user(msg, true_resp=('y', ), **kwargs):
"""
yep = u', '.join(true_resp)
nope = u'<not %s>' % yep if 'n' in true_resp or 'N' in true_resp else 'N'
msg = escape_ctrl_chars(msg).encode(pref_enc, errors='replace')
yep = yep.encode(pref_enc, errors='replace')
nope = nope.encode(pref_enc, errors='replace')
msg = escape_ctrl_chars(msg).encode(pref_enc, 'replace')
yep = yep.encode(pref_enc, 'replace')
nope = nope.encode(pref_enc, 'replace')
user_response = raw_input(
'%s [%s/%s]: ' % (msg, yep, nope))
return user_response[0].lower() in [s.lower() for s in true_resp]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment