Commit 9b81d874 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Christos Stavrakakis

Better handling of log messages

Never, ever log tokens
parent 383e5dbf
...@@ -84,9 +84,6 @@ def authenticate(token, astakos_url, usage=False, use_pool=False): ...@@ -84,9 +84,6 @@ def authenticate(token, astakos_url, usage=False, use_pool=False):
Otherwise raise an Exception. Otherwise raise an Exception.
""" """
if not token:
logger.error("authenticate: No token was given")
return None
authentication_url = urlparse.urljoin(astakos_url, "/im/authenticate") authentication_url = urlparse.urljoin(astakos_url, "/im/authenticate")
if usage: if usage:
authentication_url += "?usage=1," authentication_url += "?usage=1,"
...@@ -109,9 +106,6 @@ def getDisplayNames(token, uuids, astakos_url, use_pool=False): ...@@ -109,9 +106,6 @@ def getDisplayNames(token, uuids, astakos_url, use_pool=False):
keys and the corresponding user names as values keys and the corresponding user names as values
""" """
if not token:
logger.error("getDisplayNames: No token was give")
return None
req_headers = {'content-type': 'application/json'} req_headers = {'content-type': 'application/json'}
req_body = simplejson.dumps({'uuids': uuids}) req_body = simplejson.dumps({'uuids': uuids})
req_url = urlparse.urljoin(astakos_url, "/user_catalogs") req_url = urlparse.urljoin(astakos_url, "/user_catalogs")
...@@ -123,12 +117,10 @@ def getDisplayNames(token, uuids, astakos_url, use_pool=False): ...@@ -123,12 +117,10 @@ def getDisplayNames(token, uuids, astakos_url, use_pool=False):
def getDisplayName(token, uuid, astakos_url, use_pool=False): def getDisplayName(token, uuid, astakos_url, use_pool=False):
"""Return the displayname of a uuid (see getDisplayNames)""" """Return the displayname of a uuid (see getDisplayNames)"""
if not token:
logger.error("getDisplayName: No token was give")
return None
if not uuid: if not uuid:
logger.error("getDiplayName: No uuid was given") m = "No uuid was given"
return None logger.error(m)
raise ValueError(m)
uuid_dict = getDisplayNames(token, [uuid], astakos_url, use_pool) uuid_dict = getDisplayNames(token, [uuid], astakos_url, use_pool)
return uuid_dict.get(uuid) return uuid_dict.get(uuid)
...@@ -158,10 +150,20 @@ def _doRequest(conn, method, url, **kwargs): ...@@ -158,10 +150,20 @@ def _doRequest(conn, method, url, **kwargs):
def _callAstakos(token, url, headers={}, body=None, def _callAstakos(token, url, headers={}, body=None,
method='GET', use_pool=False): method='GET', use_pool=False):
"""Make the actual call to astakos service""" """Make the actual call to astakos service"""
logger.debug("Make a %s request to %s with token %s, " logger.debug("Make a %s request to %s with headers %s "
"headers %s and body %s, %s using the pool" % "and body %s, %s using the pool" %
(method, url, token, headers, body, (method, url, headers, body,
"not" if not use_pool else "")) "without" if not use_pool else ""))
# Check input
if not token:
m = "Token not given"
logger.error(m)
raise ValueError(m)
if not url:
m = "Url not given"
logger.error(m)
raise ValueError(m)
# Build request's header and body # Build request's header and body
kwargs = {} kwargs = {}
......
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