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

Allow non-ascii paramters on path2url

Replace calls of the form unicode(v) to the equivalent" '%s' % v
parent ff7754bd
...@@ -83,7 +83,7 @@ class Argument(object): ...@@ -83,7 +83,7 @@ class Argument(object):
if isinstance(newname, list) or isinstance(newname, tuple): if isinstance(newname, list) or isinstance(newname, tuple):
self._parsed_name += list(newname) self._parsed_name += list(newname)
else: else:
self._parsed_name.append(unicode(newname)) self._parsed_name.append('%s' % newname)
@property @property
def help(self): def help(self):
...@@ -92,7 +92,7 @@ class Argument(object): ...@@ -92,7 +92,7 @@ class Argument(object):
@help.setter @help.setter
def help(self, newhelp): def help(self, newhelp):
self._help = unicode(newhelp) self._help = '%s' % newhelp
@property @property
def arity(self): def arity(self):
...@@ -189,7 +189,7 @@ class CmdLineConfigArgument(Argument): ...@@ -189,7 +189,7 @@ class CmdLineConfigArgument(Argument):
if options == self.default: if options == self.default:
return return
if not isinstance(options, list): if not isinstance(options, list):
options = [unicode(options)] options = ['%s' % options]
for option in options: for option in options:
keypath, sep, val = option.partition('=') keypath, sep, val = option.partition('=')
if not sep: if not sep:
......
...@@ -353,7 +353,7 @@ class server_firewall(_init_cyclades): ...@@ -353,7 +353,7 @@ class server_firewall(_init_cyclades):
def _run(self, server_id, profile): def _run(self, server_id, profile):
self.client.set_firewall_profile( self.client.set_firewall_profile(
server_id=int(server_id), server_id=int(server_id),
profile=unicode(profile).upper()) profile=('%s' % profile).upper())
def main(self, server_id, profile): def main(self, server_id, profile):
super(self.__class__, self)._run() super(self.__class__, self)._run()
......
...@@ -113,7 +113,7 @@ def raiseCLIError(err, message='', importance=0, details=[]): ...@@ -113,7 +113,7 @@ def raiseCLIError(err, message='', importance=0, details=[]):
else: else:
origerr = stack[0] origerr = stack[0]
message = unicode(message) if message else unicode(origerr) message = '%s' % (message if message else origerr)
try: try:
status = err.status or err.errno status = err.status or err.errno
......
...@@ -99,6 +99,7 @@ def print_dict( ...@@ -99,6 +99,7 @@ def print_dict(
counter = 1 counter = 1
for key, val in sorted(d.items()): for key, val in sorted(d.items()):
key = '%s' % key
if key in exclude: if key in exclude:
continue continue
print_str = '' print_str = ''
...@@ -106,8 +107,8 @@ def print_dict( ...@@ -106,8 +107,8 @@ def print_dict(
print_str = '%s. ' % counter print_str = '%s. ' % counter
counter += 1 counter += 1
print_str = '%s%s' % (' ' * (ident - len(print_str)), print_str) print_str = '%s%s' % (' ' * (ident - len(print_str)), print_str)
print_str += ('%s' % key).strip() print_str += key.strip()
print_str += ' ' * (margin - len(unicode(key).strip())) print_str += ' ' * (margin - len(key.strip()))
print_str += ': ' print_str += ': '
if isinstance(val, dict): if isinstance(val, dict):
print(print_str) print(print_str)
...@@ -126,7 +127,7 @@ def print_dict( ...@@ -126,7 +127,7 @@ def print_dict(
with_enumeration=recursive_enumeration, with_enumeration=recursive_enumeration,
recursive_enumeration=recursive_enumeration) recursive_enumeration=recursive_enumeration)
else: else:
print print_str + ' ' + unicode(val).strip() print print_str + ' ' + ('%s' % val).strip()
def print_list( def print_list(
...@@ -158,7 +159,7 @@ def print_list( ...@@ -158,7 +159,7 @@ def print_list(
isinstance(item, list) or isinstance(item, list) or
item in exclude)) item in exclude))
except ValueError: except ValueError:
margin = (2 + len(unicode(len(l)))) if enumerate else 1 margin = (2 + len(('%s' % len(l)))) if enumerate else 1
counter = 1 counter = 1
prefix = '' prefix = ''
...@@ -242,9 +243,9 @@ def print_items( ...@@ -242,9 +243,9 @@ def print_items(
if isinstance(item, dict): if isinstance(item, dict):
title = sorted(set(title).intersection(item.keys())) title = sorted(set(title).intersection(item.keys()))
if with_redundancy: if with_redundancy:
header = ' '.join(unicode(item[key]) for key in title) header = ' '.join('%s' % item[key] for key in title)
else: else:
header = ' '.join(unicode(item.pop(key)) for key in title) header = ' '.join('%s' % item.pop(key) for key in title)
print(bold(header)) print(bold(header))
if isinstance(item, dict): if isinstance(item, dict):
print_dict(item, ident=1) print_dict(item, ident=1)
...@@ -305,7 +306,7 @@ def dict2file(d, f, depth=0): ...@@ -305,7 +306,7 @@ def dict2file(d, f, depth=0):
f.write('\n') f.write('\n')
list2file(v, f, depth + 1) list2file(v, f, depth + 1)
else: else:
f.write(' %s\n' % unicode(v)) f.write(' %s\n' % v)
def list2file(l, f, depth=1): def list2file(l, f, depth=1):
...@@ -315,7 +316,7 @@ def list2file(l, f, depth=1): ...@@ -315,7 +316,7 @@ def list2file(l, f, depth=1):
elif isinstance(item, list): elif isinstance(item, list):
list2file(item, f, depth + 1) list2file(item, f, depth + 1)
else: else:
f.write('%s%s\n' % ('\t' * depth, unicode(item))) f.write('%s%s\n' % ('\t' * depth, item))
# Split input auxiliary # Split input auxiliary
......
...@@ -189,7 +189,7 @@ class Client(object): ...@@ -189,7 +189,7 @@ class Client(object):
data = dumps(kwargs.pop('json')) data = dumps(kwargs.pop('json'))
self.set_default_header('Content-Type', 'application/json') self.set_default_header('Content-Type', 'application/json')
if data: if data:
self.set_default_header('Content-Length', unicode(len(data))) self.set_default_header('Content-Length', '%s' % len(data))
sendlog.info('perform a %s @ %s', method, self.base_url) sendlog.info('perform a %s @ %s', method, self.base_url)
......
...@@ -101,7 +101,8 @@ class ComputeClient(ComputeClientApi): ...@@ -101,7 +101,8 @@ class ComputeClient(ComputeClientApi):
if isinstance(err.details, list): if isinstance(err.details, list):
tmp_err = err.details tmp_err = err.details
else: else:
tmp_err = unicode(err.details).split(',') errd = '%s' % err.details
tmp_err = errd.split(',')
tmp_err = tmp_err[0].split(':') tmp_err = tmp_err[0].split(':')
tmp_err = tmp_err[2].split('"') tmp_err = tmp_err[2].split('"')
err.message = tmp_err[1] err.message = tmp_err[1]
......
...@@ -144,7 +144,7 @@ class HTTPConnection(object): ...@@ -144,7 +144,7 @@ class HTTPConnection(object):
self.method = method self.method = method
def set_header(self, name, value): def set_header(self, name, value):
self.headers[unicode(name)] = unicode(value) self.headers['%s' % name] = '%s' % value
def remove_header(self, name): def remove_header(self, name):
try: try:
......
...@@ -74,7 +74,7 @@ class KamakiHTTPResponse(HTTPResponse): ...@@ -74,7 +74,7 @@ class KamakiHTTPResponse(HTTPResponse):
:returns: (str) content :returns: (str) content
""" """
self._get_response() self._get_response()
return unicode(self._content) return '%s' % self._content
@text.setter @text.setter
def test(self, v): def test(self, v):
...@@ -123,9 +123,9 @@ class KamakiHTTPConnection(HTTPConnection): ...@@ -123,9 +123,9 @@ class KamakiHTTPConnection(HTTPConnection):
for k, v in extra_params.items(): for k, v in extra_params.items():
params[k] = v params[k] = v
for i, (key, val) in enumerate(params.items()): for i, (key, val) in enumerate(params.items()):
param_str = ('?' if i == 0 else '&') + unicode(key) param_str = '%s%s' % ('?' if i == 0 else '&', key)
if val is not None: if val is not None:
param_str += '=' + unicode(val) param_str += '=%s' % val
url += param_str url += param_str
parsed = urlparse(url) parsed = urlparse(url)
......
...@@ -229,7 +229,7 @@ class CycladesClient(CycladesClientApi): ...@@ -229,7 +229,7 @@ class CycladesClient(CycladesClientApi):
for (nic_id, network_id) in [( for (nic_id, network_id) in [(
net['id'], net['id'],
net['network_id']) for net in vm_nets if nic_id == net['id']]: net['network_id']) for net in vm_nets if nic_id == net['id']]:
req = {'remove': {'attachment': unicode(nic_id)}} req = {'remove': {'attachment': '%s' % nic_id}}
r = self.networks_post(network_id, 'action', json_data=req) r = self.networks_post(network_id, 'action', json_data=req)
r.release() r.release()
num_of_disconnections += 1 num_of_disconnections += 1
......
...@@ -89,7 +89,7 @@ def path4url(*args): ...@@ -89,7 +89,7 @@ def path4url(*args):
path = '' path = ''
for arg in args: for arg in args:
suffix = unicode(arg) suffix = '%s' % arg
try: try:
while suffix[0] == '/': while suffix[0] == '/':
suffix = suffix[1:] suffix = suffix[1:]
......
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