From 0e7a8367be16452c9a4c668e82a57acbacc47fd0 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Fri, 15 Dec 2023 13:27:58 -0500 Subject: [PATCH] fix --- pygeoapi/api.py | 54 +++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/pygeoapi/api.py b/pygeoapi/api.py index 388586bdd..d5bf3673e 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -1180,41 +1180,37 @@ def describe_collections(self, request: Union[APIRequest, Any], try: edr = get_provider_by_type(v['providers'], 'edr') + p = load_plugin('provider', edr) + except ProviderConnectionError: + msg = 'connection error (check logs)' + return self.get_exception( + HTTPStatus.INTERNAL_SERVER_ERROR, headers, + request.format, 'NoApplicableCode', msg) except ProviderTypeError: edr = None if edr: # TODO: translate LOGGER.debug('Adding EDR links') - try: - p = load_plugin('provider', get_provider_by_type( - self.config['resources'][dataset]['providers'], 'edr')) - parameters = p.get_fields() - if parameters: - collection['parameter-names'] = {} - for f in parameters['field']: - collection['parameter-names'][f['id']] = f - - for qt in p.get_query_types(): - collection['links'].append({ - 'type': 'application/json', - 'rel': 'data', - 'title': f'{qt} query for this collection as JSON', - 'href': f'{self.get_collections_url()}/{k}/{qt}?f={F_JSON}' # noqa - }) - collection['links'].append({ - 'type': FORMAT_TYPES[F_HTML], - 'rel': 'data', - 'title': f'{qt} query for this collection as HTML', - 'href': f'{self.get_collections_url()}/{k}/{qt}?f={F_HTML}' # noqa - }) - except ProviderConnectionError: - msg = 'connection error (check logs)' - return self.get_exception( - HTTPStatus.INTERNAL_SERVER_ERROR, headers, - request.format, 'NoApplicableCode', msg) - except ProviderTypeError: - pass + parameters = p.get_fields() + if parameters: + collection['parameter-names'] = {} + for f in parameters['field']: + collection['parameter-names'][f['id']] = f + + for qt in p.get_query_types(): + collection['links'].append({ + 'type': 'application/json', + 'rel': 'data', + 'title': f'{qt} query for this collection as JSON', + 'href': f'{self.get_collections_url()}/{k}/{qt}?f={F_JSON}' # noqa + }) + collection['links'].append({ + 'type': FORMAT_TYPES[F_HTML], + 'rel': 'data', + 'title': f'{qt} query for this collection as HTML', + 'href': f'{self.get_collections_url()}/{k}/{qt}?f={F_HTML}' # noqa + }) if dataset is not None and k == dataset: fcm = collection