# Path: oioswift/utils.py
# def handle_oio_timeout(fnc):
#     """
#     Catch DeadlineReached and OioTimeout errors
#     and return '503 Service Unavailable'.
#     """
#     @wraps(fnc)
#     def _oio_timeout_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (DeadlineReached, OioTimeout) as exc:
#             headers = dict()
#             # TODO(FVE): choose the value according to the timeout
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=str(exc))
#     return _oio_timeout_wrapper
# 
# def handle_service_busy(fnc):
#     @wraps(fnc)
#     def _service_busy_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (ServiceBusy, ServiceUnavailable) as err:
#             headers = dict()
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=err.message)
#     return _service_busy_wrapper
# 
# REQID_HEADER = 'x-oio-req-id'


import time
from xml.sax import saxutils
    from swift.common.middleware.listing_formats import \
        get_listing_content_type
    from swift.common.request_helpers import get_listing_content_type
from swift.common.utils import public, Timestamp, json
from swift.common.constraints import check_metadata
from swift.common import constraints
from swift.common.swob import HTTPBadRequest, HTTPMethodNotAllowed
from swift.common.request_helpers import get_param, is_sys_or_user_meta
from swift.common.swob import HTTPNoContent, HTTPOk, HTTPPreconditionFailed, \
    HTTPNotFound, HTTPCreated, HTTPAccepted
from swift.proxy.controllers.account import AccountController \
        as SwiftAccountController
from swift.proxy.controllers.base import set_info_cache, clear_info_cache
from oio.common import exceptions
from oioswift.utils import handle_oio_timeout, handle_service_busy, \
    REQID_HEADER
                         constraints.MAX_ACCOUNT_NAME_LENGTH)
            return resp

        resp = self.get_account_listing_resp(req)
        set_info_cache(self.app, req.environ, self.account_name, None, resp)

        if req.environ.get('swift_owner'):
            self.add_acls_from_sys_metadata(resp)
        else:
            for header in self.app.swift_owner_headers:
                resp.headers.pop(header, None)
        return resp

    def get_account_listing_resp(self, req):
        prefix = get_param(req, 'prefix')
        delimiter = get_param(req, 'prefix')
        if delimiter and (len(delimiter) > 1 or ord(delimiter) > 254):
            return HTTPPreconditionFailed(body='Bad delimiter')
        limit = constraints.ACCOUNT_LISTING_LIMIT
        given_limit = get_param(req, 'limit')
        if given_limit and given_limit.isdigit():
            limit = int(given_limit)
            if limit > constraints.ACCOUNT_LISTING_LIMIT:
                return HTTPPreconditionFailed(
                    request=req,
                    body='Maximum limit is %d' %
                         constraints.ACCOUNT_LISTING_LIMIT)
        marker = get_param(req, 'marker')
        end_marker = get_param(req, 'end_marker')
        s3_buckets_only = False

# Path: oioswift/utils.py
# def handle_oio_timeout(fnc):
#     """
#     Catch DeadlineReached and OioTimeout errors
#     and return '503 Service Unavailable'.
#     """
#     @wraps(fnc)
#     def _oio_timeout_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (DeadlineReached, OioTimeout) as exc:
#             headers = dict()
#             # TODO(FVE): choose the value according to the timeout
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=str(exc))
#     return _oio_timeout_wrapper
# 
# def handle_service_busy(fnc):
#     @wraps(fnc)
#     def _service_busy_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (ServiceBusy, ServiceUnavailable) as err:
#             headers = dict()
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=err.message)
#     return _service_busy_wrapper
# 
# REQID_HEADER = 'x-oio-req-id'


# Path: oioswift/proxy/controllers/account.py
import time
from xml.sax import saxutils
    from swift.common.middleware.listing_formats import \
        get_listing_content_type
    from swift.common.request_helpers import get_listing_content_type
from swift.common.utils import public, Timestamp, json
from swift.common.constraints import check_metadata
from swift.common import constraints
from swift.common.swob import HTTPBadRequest, HTTPMethodNotAllowed
from swift.common.request_helpers import get_param, is_sys_or_user_meta
from swift.common.swob import HTTPNoContent, HTTPOk, HTTPPreconditionFailed, \
    HTTPNotFound, HTTPCreated, HTTPAccepted
from swift.proxy.controllers.account import AccountController \
        as SwiftAccountController
from swift.proxy.controllers.base import set_info_cache, clear_info_cache
from oio.common import exceptions
from oioswift.utils import handle_oio_timeout, handle_service_busy, \
    REQID_HEADER

                         constraints.MAX_ACCOUNT_NAME_LENGTH)
            return resp

        resp = self.get_account_listing_resp(req)
        set_info_cache(self.app, req.environ, self.account_name, None, resp)

        if req.environ.get('swift_owner'):
            self.add_acls_from_sys_metadata(resp)
        else:
            for header in self.app.swift_owner_headers:
                resp.headers.pop(header, None)
        return resp

    def get_account_listing_resp(self, req):
        prefix = get_param(req, 'prefix')
        delimiter = get_param(req, 'prefix')
        if delimiter and (len(delimiter) > 1 or ord(delimiter) > 254):
            return HTTPPreconditionFailed(body='Bad delimiter')
        limit = constraints.ACCOUNT_LISTING_LIMIT
        given_limit = get_param(req, 'limit')
        if given_limit and given_limit.isdigit():
            limit = int(given_limit)
            if limit > constraints.ACCOUNT_LISTING_LIMIT:
                return HTTPPreconditionFailed(
                    request=req,
                    body='Maximum limit is %d' %
                         constraints.ACCOUNT_LISTING_LIMIT)
        marker = get_param(req, 'marker')
        end_marker = get_param(req, 'end_marker')
        s3_buckets_only = False

        oio_headers = {REQID_HEADER: self.trans_id}