Skip to content

Commit

Permalink
Updated sparql_json_vocabulary_terms to use invalid_url helper whic…
Browse files Browse the repository at this point in the history
…h uses user-agent and retries to get response
  • Loading branch information
MarkCalvert committed Aug 10, 2023
1 parent 689b16e commit 5aa6047
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ckanext/vocabulary_services/logic/action/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ckan.plugins.toolkit import get_action
from ckanext.vocabulary_services import helpers, model
from pprint import pformat
from ckanext.invalid_uris.helpers import valid_uri as uri_response
from sqlalchemy import or_

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -56,14 +56,14 @@ def sparql_json_vocabulary_terms(context, data_dict):

if service_id and service_uri:
try:
r = requests.get(service_uri)

log.debug('>>> Request status code: %s' % r.status_code)
result = uri_response(service_uri)
log.debug('>>> Request status code: %s' % result.get('status_code'))

if r.status_code == 200:
if result.get('status_code') == 200 and result.get('response'):
log.debug('>>> Finished fetching vocabulary from SPARQL+JSON service.')

response = r.json()
response = result.get('response').json()

# If you open the https://vocabs.gsq.digital... URI above, you can see that the terms are
# contained in the 'results' dict element, and the 'bindings' element beneath that.
Expand Down

0 comments on commit 5aa6047

Please sign in to comment.