Merge pull request #191 from raphaelstolt/master
Catch JSONDecodeError when no JSON content
This commit is contained in:
commit
5f96346487
|
@ -6,6 +6,7 @@ from ckan.model import Session, Package
|
||||||
from ckan.logic import ValidationError, NotFound, get_action
|
from ckan.logic import ValidationError, NotFound, get_action
|
||||||
from ckan.lib.helpers import json
|
from ckan.lib.helpers import json
|
||||||
from ckan.lib.munge import munge_name
|
from ckan.lib.munge import munge_name
|
||||||
|
from simplejson.scanner import JSONDecodeError
|
||||||
|
|
||||||
from ckanext.harvest.model import HarvestJob, HarvestObject, HarvestGatherError, \
|
from ckanext.harvest.model import HarvestJob, HarvestObject, HarvestGatherError, \
|
||||||
HarvestObjectError
|
HarvestObjectError
|
||||||
|
@ -221,10 +222,13 @@ class CKANHarvester(HarvesterBase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = self._get_content(url)
|
content = self._get_content(url)
|
||||||
|
package_ids = json.loads(content)
|
||||||
except ContentFetchError,e:
|
except ContentFetchError,e:
|
||||||
self._save_gather_error('Unable to get content for URL: %s: %s' % (url, str(e)),harvest_job)
|
self._save_gather_error('Unable to get content for URL: %s: %s' % (url, str(e)),harvest_job)
|
||||||
return None
|
return None
|
||||||
package_ids = json.loads(content)
|
except JSONDecodeError,e:
|
||||||
|
self._save_gather_error('Unable to decode content for URL: %s: %s' % (url, str(e)),harvest_job)
|
||||||
|
return None
|
||||||
|
|
||||||
if org_filter_include:
|
if org_filter_include:
|
||||||
package_ids = set(package_ids) & include_pkg_ids
|
package_ids = set(package_ids) & include_pkg_ids
|
||||||
|
|
Loading…
Reference in New Issue