Repository: rucio/rucio

Issue:
No exceptions handled for list_rse_attributes
Motivation
----------
No exceptions are handled for list_rse_attributes in the REST API, in particular RSENotFound




Discussion:

Resolving patch:
diff --git a/lib/rucio/web/rest/flaskapi/v1/rse.py b/lib/rucio/web/rest/flaskapi/v1/rse.py
--- a/lib/rucio/web/rest/flaskapi/v1/rse.py
+++ b/lib/rucio/web/rest/flaskapi/v1/rse.py
@@ -17,10 +17,11 @@
 # - Vincent Garonne <vincent.garonne@cern.ch>, 2012-2017
 # - Thomas Beermann <thomas.beermann@cern.ch>, 2012-2018
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2013-2014
-# - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2016
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2018
 # - Martin Barisits <martin.barisits@cern.ch>, 2017
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2018
 
+from __future__ import print_function
 from json import dumps, loads
 from traceback import format_exc
 from flask import Flask, Blueprint, Response, request
@@ -68,11 +69,11 @@ def get(self):
                     item = {'rse': rse}
                     data += render_json(**item) + '\n'
                 return Response(data, content_type="application/x-json-stream")
-            except InvalidRSEExpression, error:
+            except InvalidRSEExpression as error:
                 return generate_http_error_flask(400, 'InvalidRSEExpression', error.args[0])
-            except InvalidObject, error:
+            except InvalidObject as error:
                 return generate_http_error_flask(400, 'InvalidObject', error.args[0])
-            except RucioException, error:
+            except RucioException as error:
                 return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
         else:
             data = ""
@@ -123,19 +124,19 @@ def post(self, rse):
         kwargs['issuer'] = request.environ.get('issuer')
         try:
             add_rse(rse, **kwargs)
-        except InvalidObject, error:
+        except InvalidObject as error:
             return generate_http_error_flask(400, 'InvalidObject', error.args[0])
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except Duplicate, error:
+        except Duplicate as error:
             return generate_http_error_flask(409, 'Duplicate', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
 
         return "Created", 201
@@ -166,19 +167,19 @@ def put(self, rse):
         kwargs['issuer'] = request.environ.get('issuer')
         try:
             update_rse(rse, **kwargs)
-        except InvalidObject, error:
+        except InvalidObject as error:
             return generate_http_error_flask(400, 'InvalidObject', error.args[0])
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except Duplicate, error:
+        except Duplicate as error:
             return generate_http_error_flask(409, 'Duplicate', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
 
         return "Created", 201
@@ -200,9 +201,9 @@ def get(self, rse):
         try:
             rse_prop = get_rse(rse=rse)
             return Response(render_json(**rse_prop), content_type="application/json")
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
 
     def delete(self, rse):
@@ -219,9 +220,9 @@ def delete(self, rse):
         """
         try:
             del_rse(rse=rse, issuer=request.environ.get('issuer'))
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
 
         return "OK", 200
@@ -254,16 +255,16 @@ def post(self, rse, key):
 
         try:
             value = parameter['value']
-        except KeyError, error:
+        except KeyError as error:
             return generate_http_error_flask(400, 'KeyError', '%s not defined' % str(error))
 
         try:
             add_rse_attribute(rse=rse, key=key, value=value, issuer=request.environ.get('issuer'))
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except Duplicate, error:
+        except Duplicate as error:
             return generate_http_error_flask(409, 'Duplicate', error[0])
-        except Exception, error:
+        except Exception as error:
             return error, 500
 
         return "Created", 201
@@ -282,8 +283,15 @@ def get(self, rse):
         :returns: A list containing all RSE attributes.
 
         """
-
-        return Response(dumps(list_rse_attributes(rse)), content_type="application/json")
+        try:
+            rse_attr = list_rse_attributes(rse)
+        except AccessDenied as error:
+            return generate_http_error_flask(401, 'AccessDenied', error.args[0])
+        except RSENotFound as error:
+            return generate_http_error_flask(404, 'RSENotFound', error.args[0])
+        except Exception as error:
+            return error, 500
+        return Response(dumps(rse_attr), content_type="application/json")
 
     def delete(self, rse, key):
         """ Delete an RSE attribute for given RSE name.
@@ -299,11 +307,11 @@ def delete(self, rse, key):
         """
         try:
             del_rse_attribute(rse=rse, key=key, issuer=request.environ.get('issuer'))
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except Exception, error:
+        except Exception as error:
             return error, 500
 
         return "OK", 200
@@ -332,17 +340,17 @@ def get(self, rse):
         p_list = None
         try:
             p_list = get_rse_protocols(rse, issuer=request.environ.get('issuer'))
-        except RSEOperationNotSupported, error:
+        except RSEOperationNotSupported as error:
             return generate_http_error_flask(404, 'RSEOperationNotSupported', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RSEProtocolNotSupported, error:
+        except RSEProtocolNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolNotSupported', error.args[0])
-        except RSEProtocolDomainNotSupported, error:
+        except RSEProtocolDomainNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolDomainNotSupported', error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
         if len(p_list['protocols']):
             return Response(dumps(p_list['protocols']), content_type="application/json")
@@ -391,15 +399,15 @@ def get(self, rse, scheme=None):
         rse_settings = None
         try:
             rse_settings = get_rse_protocols(rse, issuer=request.environ.get('issuer'))
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RSEProtocolNotSupported, error:
+        except RSEProtocolNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolNotSupported', error.args[0])
-        except RSEProtocolDomainNotSupported, error:
+        except RSEProtocolDomainNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolDomainNotSupported', error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
 
         pfns = rsemanager.lfns2pfns(rse_settings, lfns, operation=operation, scheme=scheme, domain=domain)
@@ -438,23 +446,23 @@ def post(self, rse, scheme):
 
         try:
             add_protocol(rse, issuer=request.environ.get('issuer'), data=parameters)
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except Duplicate, error:
+        except Duplicate as error:
             return generate_http_error_flask(409, 'Duplicate', error.args[0])
-        except InvalidObject, error:
+        except InvalidObject as error:
             return generate_http_error_flask(400, 'InvalidObject', error.args[0])
-        except RSEProtocolDomainNotSupported, error:
+        except RSEProtocolDomainNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolDomainNotSupported', error.args[0])
-        except RSEProtocolPriorityError, error:
+        except RSEProtocolPriorityError as error:
             return generate_http_error_flask(409, 'RSEProtocolPriorityError', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print (format_exc())
             return error, 500
         return "Created", 201
 
@@ -477,15 +485,15 @@ def get(self, rse, scheme):
         p_list = None
         try:
             p_list = get_rse_protocols(rse, issuer=request.environ.get('issuer'))
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RSEProtocolNotSupported, error:
+        except RSEProtocolNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolNotSupported', error.args[0])
-        except RSEProtocolDomainNotSupported, error:
+        except RSEProtocolDomainNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolDomainNotSupported', error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
         return Response(dumps(p_list), content_type="application/json")
 
@@ -519,21 +527,21 @@ def put(self, rse, scheme, hostname=None, port=None):
 
         try:
             update_protocols(rse, issuer=request.environ.get('issuer'), scheme=scheme, hostname=hostname, port=port, data=parameter)
-        except InvalidObject, error:
+        except InvalidObject as error:
             return generate_http_error_flask(400, 'InvalidObject', error.args[0])
-        except RSEProtocolNotSupported, error:
+        except RSEProtocolNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolNotSupported', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RSEProtocolDomainNotSupported, error:
+        except RSEProtocolDomainNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolDomainNotSupported', error.args[0])
-        except RSEProtocolPriorityError, error:
+        except RSEProtocolPriorityError as error:
             return generate_http_error_flask(409, 'RSEProtocolPriorityError', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
 
         return "OK", 200
@@ -557,15 +565,15 @@ def delete(self, rse, scheme, hostname=None, port=None):
         """
         try:
             del_protocols(rse, issuer=request.environ.get('issuer'), scheme=scheme, hostname=hostname, port=port)
-        except RSEProtocolNotSupported, error:
+        except RSEProtocolNotSupported as error:
             return generate_http_error_flask(404, 'RSEProtocolNotSupported', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print error
-            print format_exc()
+        except Exception as error:
+            print(error)
+            print(format_exc())
             return error, 500
 
         return "OK", 200
@@ -595,12 +603,12 @@ def get(self, rse):
 
         try:
             usage = get_rse_usage(rse, issuer=request.environ.get('issuer'), source=source)
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
         data = ""
@@ -630,14 +638,14 @@ def put(self, rse):
 
         try:
             set_rse_usage(rse=rse, issuer=request.environ.get('issuer'), **parameter)
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
         return "OK", 200
@@ -668,12 +676,12 @@ def get(self, rse):
             for usage in list_rse_usage_history(rse=rse, issuer=request.environ.get('issuer'), source=source):
                 data = render_json(**usage) + '\n'
             return Response(data, content_type="application/x-json-stream")
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
 
@@ -698,12 +706,12 @@ def get(self, rse):
         try:
             limits = get_rse_limits(rse=rse, issuer=request.environ.get('issuer'))
             return Response(render_json(**limits), content_type="application/json")
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
     def put(self, rse):
@@ -726,14 +734,14 @@ def put(self, rse):
             return generate_http_error_flask(400, 'ValueError', 'Cannot decode json parameter dictionary')
         try:
             set_rse_limits(rse=rse, issuer=request.environ.get('issuer'), **parameter)
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
         return "OK", 200
@@ -763,12 +771,12 @@ def get(self, rse):
             for row in usage:
                 data = dumps(row, cls=APIEncoder) + '\n'
             return Response(data, content_type="application/json")
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
 
@@ -795,12 +803,12 @@ def get(self, source, destination):
                                     destination=destination,
                                     issuer=request.environ.get('issuer'))
             return Response(dumps(distance, cls=APIEncoder), content_type="application/json")
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
 
     def post(self, source, destination):
@@ -827,14 +835,14 @@ def post(self, source, destination):
                          destination=destination,
                          issuer=request.environ.get('issuer'),
                          **parameter)
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
         return "Created", 201
 
@@ -860,14 +868,14 @@ def put(self, source, destination):
             update_distance(source=source, destination=destination,
                             issuer=request.environ.get('issuer'),
                             parameters=parameters)
-        except AccessDenied, error:
+        except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
-        except RSENotFound, error:
+        except RSENotFound as error:
             return generate_http_error_flask(404, 'RSENotFound', error.args[0])
-        except RucioException, error:
+        except RucioException as error:
             return generate_http_error_flask(500, error.__class__.__name__, error.args[0])
-        except Exception, error:
-            print format_exc()
+        except Exception as error:
+            print(format_exc())
             return error, 500
         return "OK", 200
 
diff --git a/lib/rucio/web/rest/webpy/v1/rse.py b/lib/rucio/web/rest/webpy/v1/rse.py
--- a/lib/rucio/web/rest/webpy/v1/rse.py
+++ b/lib/rucio/web/rest/webpy/v1/rse.py
@@ -17,10 +17,11 @@
 # - Vincent Garonne <vincent.garonne@cern.ch>, 2012-2017
 # - Thomas Beermann <thomas.beermann@cern.ch>, 2012, 2014
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2013-2014
-# - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2016
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2018
 # - Martin Barisits <martin.barisits@cern.ch>, 2017
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2018
 
+from __future__ import print_function
 from json import dumps, loads
 from traceback import format_exc
 from urlparse import parse_qs, parse_qsl
@@ -141,8 +142,8 @@ def POST(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
 
         raise Created()
@@ -183,8 +184,8 @@ def PUT(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
 
         raise Created()
@@ -290,7 +291,17 @@ def GET(self, rse):
         :returns: A list containing all RSE attributes.
         """
         header('Content-Type', 'application/json')
-        return dumps(list_rse_attributes(rse))
+        try:
+            rse_attr = list_rse_attributes(rse)
+        except AccessDenied as error:
+            raise generate_http_error(401, 'AccessDenied', error.args[0])
+        except RSENotFound as error:
+            raise generate_http_error(404, 'RSENotFound', error.args[0])
+        except Exception as error:
+            print(format_exc())
+            raise InternalError(error)
+
+        return dumps(rse_attr)
 
     def DELETE(self, rse, key):
         try:
@@ -333,8 +344,8 @@ def GET(self, rse):
         except RSEProtocolDomainNotSupported as error:
             raise generate_http_error(404, 'RSEProtocolDomainNotSupported', error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
         if len(p_list['protocols']):
             return dumps(p_list['protocols'])
@@ -401,8 +412,8 @@ def GET(self, rse, scheme=None):
         except RSEProtocolDomainNotSupported as error:
             raise generate_http_error(404, 'RSEProtocolDomainNotSupported', error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
 
         pfns = rsemanager.lfns2pfns(rse_settings, lfns, operation=operation, scheme=scheme, domain=domain)
@@ -453,8 +464,8 @@ def POST(self, rse, scheme):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
         raise Created()
 
@@ -481,8 +492,8 @@ def GET(self, rse, scheme):
         except RSEProtocolDomainNotSupported as error:
             raise generate_http_error(404, 'RSEProtocolDomainNotSupported', error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
         return dumps(p_list)
 
@@ -522,8 +533,8 @@ def PUT(self, rse, scheme, hostname=None, port=None):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
 
         raise OK()
@@ -549,8 +560,8 @@ def DELETE(self, rse, scheme, hostname=None, port=None):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print error
-            print format_exc()
+            print(error)
+            print(format_exc())
             raise InternalError(error)
 
         raise OK()
@@ -580,7 +591,7 @@ def GET(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
         for u in usage:
@@ -616,7 +627,7 @@ def PUT(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
         raise OK()
@@ -646,7 +657,7 @@ def GET(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
 
@@ -668,7 +679,7 @@ def GET(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
     def PUT(self, rse):
@@ -701,7 +712,7 @@ def PUT(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
         raise OK()
@@ -726,7 +737,7 @@ def GET(self, rse):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
 
@@ -750,7 +761,7 @@ def GET(self, source, destination):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
 
     def POST(self, source, destination):
@@ -786,7 +797,7 @@ def POST(self, source, destination):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
         raise Created()
 
@@ -822,7 +833,7 @@ def PUT(self, source, destination):
         except RucioException as error:
             raise generate_http_error(500, error.__class__.__name__, error.args[0])
         except Exception as error:
-            print format_exc()
+            print(format_exc())
             raise InternalError(error)
         raise OK()
 


Test patch: