From 5fee4d6d19b9952c5b19e25047e1dd3b791335cc Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 17 Oct 2016 15:21:11 -0400 Subject: [PATCH] *: misc formatting cleanup --- endpoints/v2/__init__.py | 28 ++++++++++++++-------------- util/config/provider/baseprovider.py | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/endpoints/v2/__init__.py b/endpoints/v2/__init__.py index aab985353..26150f875 100644 --- a/endpoints/v2/__init__.py +++ b/endpoints/v2/__init__.py @@ -31,6 +31,19 @@ license_validator.enforce_license_before_request(v2_bp) time_blueprint(v2_bp, metric_queue) +@v2_bp.app_errorhandler(V2RegistryException) +def handle_registry_v2_exception(error): + response = jsonify({ + 'errors': [error.as_dict()] + }) + + response.status_code = error.http_status_code + if response.status_code == 401: + response.headers.extend(get_auth_headers(repository=error.repository, scopes=error.scopes)) + logger.debug('sending response: %s', response.get_data()) + return response + + _MAX_RESULTS_PER_PAGE = 50 @@ -75,19 +88,6 @@ def paginate(limit_kwarg_name='limit', offset_kwarg_name='offset', return wrapper -@v2_bp.app_errorhandler(V2RegistryException) -def handle_registry_v2_exception(error): - response = jsonify({ - 'errors': [error.as_dict()] - }) - - response.status_code = error.http_status_code - if response.status_code == 401: - response.headers.extend(get_auth_headers(repository=error.repository, scopes=error.scopes)) - logger.debug('sending response: %s', response.get_data()) - return response - - def _require_repo_permission(permission_class, scopes=None, allow_public=False): def wrapper(func): @wraps(func) @@ -120,7 +120,6 @@ def get_input_stream(flask_request): return flask_request.stream -# TODO remove when v2 is deployed everywhere def route_show_if(value): def decorator(f): @wraps(f) @@ -132,6 +131,7 @@ def route_show_if(value): return decorated_function return decorator + @v2_bp.route('/') @route_show_if(features.ADVERTISE_V2) @process_registry_jwt_auth() diff --git a/util/config/provider/baseprovider.py b/util/config/provider/baseprovider.py index d3bea873e..ad7768de9 100644 --- a/util/config/provider/baseprovider.py +++ b/util/config/provider/baseprovider.py @@ -103,10 +103,10 @@ class BaseProvider(object): def _get_license_file(self): """ Returns the contents of the license file. """ try: - return self.get_volume_file(LICENSE_FILENAME) + return self.get_volume_file(LICENSE_FILENAME) except IOError: - msg = 'Could not open license file. Please make sure it is in your config volume.' - raise LicenseError(msg) + msg = 'Could not open license file. Please make sure it is in your config volume.' + raise LicenseError(msg) def validate_license(self, config): """ Validates that the configuration matches the license file (if any). """