protect against errors from the hound API
When codesearch.o.o is re-indexing the API responds with something that is not JSON. Rather than worry about all of the various errors we could receive from an API that is only providing advisory information, catch anything, log it, and proceed in a safe manner. Change-Id: Ia910215029b3ece31db180396dbb50c82a7f3a59 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
3c9b15af15
commit
a0c983e0b8
@ -16,9 +16,12 @@
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_URL = 'http://codesearch.openstack.org/api/v1/search'
|
||||
|
||||
|
||||
@ -39,6 +42,7 @@ def _query(q, **kwds):
|
||||
|
||||
|
||||
def get_dependency_listings(package_name):
|
||||
try:
|
||||
return _query(
|
||||
q=package_name,
|
||||
# NOTE(dhellmann): Including setup.cfg shows *lots* of results
|
||||
@ -47,6 +51,10 @@ def get_dependency_listings(package_name):
|
||||
# those.
|
||||
files='(.*requirements.txt|.*constraint.*.txt)',
|
||||
)
|
||||
except Exception as e:
|
||||
LOG.error('Could not fetch users of %s: %s',
|
||||
package_name, e)
|
||||
return {}
|
||||
|
||||
|
||||
def show_dependency_listings(package_name, official_repos):
|
||||
|
Loading…
Reference in New Issue
Block a user