mirror of https://github.com/MISP/misp-modules
fix: Handling cases where there is no result from the query
parent
f27031d522
commit
5d4a0bff98
|
@ -26,13 +26,12 @@ def handler(q=False):
|
||||||
sparql.setQuery(query_string)
|
sparql.setQuery(query_string)
|
||||||
sparql.setReturnFormat(JSON)
|
sparql.setReturnFormat(JSON)
|
||||||
results = sparql.query().convert()
|
results = sparql.query().convert()
|
||||||
|
|
||||||
summary = ''
|
summary = ''
|
||||||
try:
|
try:
|
||||||
result = results["results"]["bindings"][0]
|
result = results["results"]["bindings"]
|
||||||
summary = result["item"]["value"]
|
summary = result[0]["item"]["value"] if result else 'No additional data found on Wikidata'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
misperrors['error'] = 'wikidata API not accessible' + e
|
misperrors['error'] = 'wikidata API not accessible {}'.format(e)
|
||||||
return misperrors['error']
|
return misperrors['error']
|
||||||
|
|
||||||
r = {'results': [{'types': mispattributes['output'], 'values': summary}]}
|
r = {'results': [{'types': mispattributes['output'], 'values': summary}]}
|
||||||
|
|
Loading…
Reference in New Issue