Skip to content

Commit 2d1a5fc

Browse files
committed
gis fetcher fixes
1 parent 5b2ee77 commit 2d1a5fc

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

datacity_ckan_dgp/ckan/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def api_request(method, instance_name, action_name, auth=True, **kwargs):
2020
headers = {'Authorization': api_key} if auth and api_key else {}
2121
if "://data.gov.il" in url:
2222
headers['user-agent'] = 'datagov-external-client'
23+
if 'verify' not in kwargs:
24+
kwargs['verify'] = os.getenv("CKAN_VERIFY_SSL") != "no"
2325
res = getattr(requests, method.lower())(url, headers=headers, **kwargs)
2426
try:
2527
return res.json()

datacity_ckan_dgp/operators/gis_fetcher.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ def gis_query_geojson_iterate_all(gis_url):
2828
'resultRecordCount': result_record_count
2929
}
3030
res = requests.get(url, params=params)
31-
res.raise_for_status()
32-
data = res.json()
33-
assert data['type'] == 'FeatureCollection'
34-
if not data['features']:
35-
break
36-
for feature in data['features']:
37-
yield feature
38-
result_offset += 1
31+
try:
32+
assert res.status_code == 200
33+
data = res.json()
34+
assert data['type'] == 'FeatureCollection'
35+
if not data['features']:
36+
break
37+
for feature in data['features']:
38+
yield feature
39+
result_offset += 1
40+
except Exception as e:
41+
raise Exception(f'failed to fetch geojson from {url} with params {params}\n{res.content}') from e
3942

4043

4144
def iterate_gis_jsonlines(tmpdir):

0 commit comments

Comments
 (0)