Commit 1accf2cb authored by Stavros Sachtouris's avatar Stavros Sachtouris

Unescape escaped names before printing to console

parent 8fa75180
......@@ -203,7 +203,15 @@ class server_list(_CycladesInit, OptionalOutput, NameFilter, IDFilter):
detail = self['detail'] or (
withimage or withflavor or withmeta or withcommons)
ch_since = self.arguments['since'].isoformat if self['since'] else None
servers = self.client.list_servers(detail, ch_since)
servers = list(self.client.list_servers(detail, ch_since) or [])
for item in servers:
for k in ('name', ):
item[k] = item[k].decode('unicode_escape')
if 'metadata' in item:
ms = dict()
for k, v in item['metadata'].items():
ms[k.decode('unicode_escape')] = v.decode('unicode_escape')
item['metadata'] = ms
servers = self._filter_by_name(servers)
servers = self._filter_by_id(servers)
......@@ -267,6 +275,12 @@ class server_info(_CycladesInit, OptionalOutput):
self.print_(self.client.get_server_diagnostics(server_id))
else:
vm = self.client.get_server_details(server_id)
vm['name'] = vm.get('name', '').decode('unicode_escape')
if 'metadata' in vm:
ms = dict()
for k, v in vm['metadata'].items():
ms[k.decode('unicode_escape')] = v.decode('unicode_escape')
vm['metadata'] = ms
self.print_(vm, self.print_dict)
def main(self, server_id):
......
......@@ -203,6 +203,8 @@ class image_list(_ImageInit, OptionalOutput, NameFilter, IDFilter):
'detail', 'prop', 'prop_like', 'owner', 'owner_name')])
images = self.client.list_public(detail, filters, order)
for img in images:
img['name'] = img['name'].decode('unicode_escape')
if self['owner'] or self['owner_name']:
images = self._filter_by_owner(images)
......
......@@ -283,7 +283,7 @@ class file_list(_PithosContainer, OptionalOutput, NameFilter):
@errors.Pithos.container
def _container_info(self):
return self.client.container_get(
r = self.client.container_get(
limit=False if self['more'] else self['limit'],
marker=self['marker'],
prefix=self.path,
......@@ -295,13 +295,19 @@ class file_list(_PithosContainer, OptionalOutput, NameFilter):
if_unmodified_since=self['if_unmodified_since'],
until=self['until'],
meta=self['meta'])
files = list(r.json or [])
for item in files:
for k in ('name', ):
if k in item:
item[k] = item[k].decode('unicode_escape')
return files
@errors.Generic.all
@errors.Pithos.connection
@errors.Pithos.object_path
def _run(self):
r = self._container_info()
if not r.json:
if not r:
if self.path:
obj_path = '/%s/%s' % (self.container, self.path)
obj_info = self.client.get_object_info(self.path)
......@@ -324,7 +330,7 @@ class file_list(_PithosContainer, OptionalOutput, NameFilter):
else:
self.error('Container "%s" is empty' % self.client.container)
files = self._filter_by_name(r.json)
files = self._filter_by_name(r)
if self['more']:
outbu, self._out = self._out, StringIO()
try:
......@@ -1595,7 +1601,12 @@ class container_list(_PithosAccount, OptionalOutput, NameFilter):
until=self['until_date'],
show_only_shared=self['shared_by_me'],
public=self['public'])
files = self._filter_by_name(r.json)
items = list(r.json or [])
for item in items:
for k in ('name', ):
if k in item:
item[k] = item[k].decode('unicode_escape')
files = self._filter_by_name(items)
if self['recursive'] and not container:
self._create_object_forest(files)
if self['more']:
......
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