Commit 8f80bf81 authored by Stratos Psomadakis's avatar Stratos Psomadakis Committed by Christos Stavrakakis
Browse files

Move exception handling in get_user()

parent 330f8e66
......@@ -132,10 +132,7 @@ class Command(BaseCommand):
user = server.userid
if not options['use_uuids']:
try:
user = ucache.get_user(server.userid)
except:
pass
user = ucache.get_user(server.userid)
fields = (str(server.id), name, user, flavor, image,
state, str(server.backend))
......
......@@ -263,15 +263,26 @@ def pprint_table(out, table, headers=None, separator=None):
class UUIDCache(object):
"""UUUID-to-email cache
"""
astakos_url = ASTAKOS_URL.replace("im/authenticate",
"service/api/user_catalogs")
def __init__(self):
self.users = {}
def get_user(self, uuid):
"""Do the uuid-to-email resolving
"""
if not uuid in self.users:
astakos_url = ASTAKOS_URL.replace("im/authenticate",
"service/api/user_catalogs")
self.users[uuid] = \
astakos.get_displayname(token=CYCLADES_ASTAKOS_SERVICE_TOKEN,
url=astakos_url, uuid=uuid)
try:
self.users[uuid] = \
astakos.get_displayname(token=CYCLADES_ASTAKOS_SERVICE_TOKEN,
url=UUIDCache.astakos_url, uuid=uuid)
except Exception:
return uuid
return self.users[uuid]
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