Revision a5b748c2
b/kamaki/cli/commands/__init__.py | ||
---|---|---|
98 | 98 |
self.cloud = cloud or getattr(self, 'cloud', None) |
99 | 99 |
|
100 | 100 |
def write(self, s): |
101 |
self._out.write(u'%s' % s)
|
|
101 |
self._out.write('%s' % s) |
|
102 | 102 |
self._out.flush() |
103 | 103 |
|
104 | 104 |
def writeln(self, s=''): |
105 |
self.write(u'%s\n' % s)
|
|
105 |
self.write('%s\n' % s) |
|
106 | 106 |
|
107 | 107 |
def error(self, s=''): |
108 |
self._err.write(u'%s\n' % s)
|
|
108 |
self._err.write('%s\n' % s) |
|
109 | 109 |
self._err.flush() |
110 | 110 |
|
111 | 111 |
def print_list(self, *args, **kwargs): |
b/kamaki/cli/utils/__init__.py | ||
---|---|---|
166 | 166 |
v, exclude, indent + INDENT_TAB, |
167 | 167 |
recursive_enumeration, recursive_enumeration, out) |
168 | 168 |
else: |
169 |
out.write(u'%s %s\n' % (print_str, v))
|
|
169 |
out.write('%s %s\n' % (print_str, v)) |
|
170 | 170 |
out.flush() |
171 | 171 |
|
172 | 172 |
|
... | ... | |
214 | 214 |
if with_enumeration: |
215 | 215 |
out.write(print_str + '\n') |
216 | 216 |
elif i and i < len(l): |
217 |
out.write(u'\n')
|
|
217 |
out.write('\n') |
|
218 | 218 |
print_list( |
219 | 219 |
item, exclude, indent + INDENT_TAB, |
220 | 220 |
recursive_enumeration, recursive_enumeration, out) |
... | ... | |
222 | 222 |
item = ('%s' % item).strip() |
223 | 223 |
if item in exclude: |
224 | 224 |
continue |
225 |
out.write(u'%s%s\n' % (print_str, item))
|
|
225 |
out.write('%s%s\n' % (print_str, item)) |
|
226 | 226 |
out.flush() |
227 | 227 |
out.flush() |
228 | 228 |
|
... | ... | |
247 | 247 |
return |
248 | 248 |
if not (isinstance(items, dict) or isinstance(items, list) or isinstance( |
249 | 249 |
items, tuple)): |
250 |
out.write(u'%s\n' % items)
|
|
250 |
out.write('%s\n' % items) |
|
251 | 251 |
out.flush() |
252 | 252 |
return |
253 | 253 |
|
254 | 254 |
for i, item in enumerate(items): |
255 | 255 |
if with_enumeration: |
256 |
out.write(u'%s. ' % (i + 1))
|
|
256 |
out.write('%s. ' % (i + 1)) |
|
257 | 257 |
if isinstance(item, dict): |
258 | 258 |
item = dict(item) |
259 | 259 |
title = sorted(set(title).intersection(item)) |
260 | 260 |
pick = item.get if with_redundancy else item.pop |
261 |
header = u' '.join(u'%s' % pick(key) for key in title)
|
|
261 |
header = ' '.join('%s' % pick(key) for key in title)
|
|
262 | 262 |
out.write((unicode(bold(header) if header else '') + '\n')) |
263 | 263 |
print_dict(item, indent=INDENT_TAB, out=out) |
264 | 264 |
elif isinstance(item, list) or isinstance(item, tuple): |
265 | 265 |
print_list(item, indent=INDENT_TAB, out=out) |
266 | 266 |
else: |
267 |
out.write(u' %s\n' % item)
|
|
267 |
out.write(' %s\n' % item) |
|
268 | 268 |
out.flush() |
269 | 269 |
out.flush() |
270 | 270 |
|
... | ... | |
389 | 389 |
""" |
390 | 390 |
yep = ', '.join(true_resp) |
391 | 391 |
nope = '<not %s>' % yep if 'n' in true_resp or 'N' in true_resp else 'N' |
392 |
out.write(u'%s [%s/%s]: ' % (msg, yep, nope))
|
|
392 |
out.write('%s [%s/%s]: ' % (msg, yep, nope)) |
|
393 | 393 |
out.flush() |
394 | 394 |
user_response = user_in.readline() |
395 | 395 |
return user_response[0].lower() in [s.lower() for s in true_resp] |
b/kamaki/clients/__init__.py | ||
---|---|---|
123 | 123 |
url += _encode(path[1:] if path.startswith('/') else path) |
124 | 124 |
delim = '?' |
125 | 125 |
for key, val in params.items(): |
126 |
val = '' if val in (None, False) else _encode(u'%s' % val)
|
|
126 |
val = '' if val in (None, False) else _encode('%s' % val) |
|
127 | 127 |
url += '%s%s%s' % (delim, key, ('=%s' % val) if val else '') |
128 | 128 |
delim = '&' |
129 | 129 |
parsed = urlparse(url) |
... | ... | |
421 | 421 |
|
422 | 422 |
def set_param(self, name, value=None, iff=True): |
423 | 423 |
if iff: |
424 |
self.params[name] = unicode(value) |
|
424 |
self.params[name] = '%s' % value # unicode(value)
|
|
425 | 425 |
|
426 | 426 |
def request( |
427 | 427 |
self, method, path, |
Also available in: Unified diff