|
46 | 46 | from dateutil.parser import parse as parsedate |
47 | 47 |
|
48 | 48 | from rq import get_current_job |
| 49 | +from ckan import plugins |
49 | 50 | import ckan.plugins.toolkit as tk |
50 | 51 |
|
51 | 52 |
|
52 | 53 | import ckanext.datapusher_plus.utils as utils |
53 | 54 | import ckanext.datapusher_plus.helpers as dph |
54 | 55 | # from ckanext.datapusher_plus.config import config |
| 56 | +from ckanext.datapusher_plus import interfaces |
| 57 | + |
| 58 | +log = logging.getLogger(__name__) |
55 | 59 |
|
56 | 60 |
|
57 | 61 | if locale.getdefaultlocale()[0]: |
@@ -149,6 +153,7 @@ def send_resource_to_datastore( |
149 | 153 | """ |
150 | 154 | Stores records in CKAN datastore |
151 | 155 | """ |
| 156 | + log.info(f"Sending data to datastore {resource_id}") |
152 | 157 |
|
153 | 158 | if resource_id: |
154 | 159 | # used to create the "main" resource |
@@ -338,6 +343,7 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None): |
338 | 343 | logger.addHandler(logging.StreamHandler()) |
339 | 344 | logger.setLevel(logging.DEBUG) |
340 | 345 |
|
| 346 | + logger.info(f"_push_to_datastore :: {task_id}") |
341 | 347 | # check if QSV_BIN and FILE_BIN exists |
342 | 348 | qsv_bin = tk.config.get("ckanext.datapusher_plus.qsv_bin") |
343 | 349 | qsv_path = Path(qsv_bin) |
@@ -441,6 +447,7 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None): |
441 | 447 | if USE_PROXY: |
442 | 448 | kwargs["proxies"] = {"http": DOWNLOAD_PROXY, "https": DOWNLOAD_PROXY} |
443 | 449 | with requests.get(resource_url, **kwargs) as response: |
| 450 | + logger.info(f"Response status {response.status_code} for {resource_url}") |
444 | 451 | response.raise_for_status() |
445 | 452 |
|
446 | 453 | cl = response.headers.get("content-length") |
@@ -1008,6 +1015,14 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None): |
1008 | 1015 | info_dict = dict(label=original_header_dict.get(idx, "Unnamed Column")) |
1009 | 1016 | headers_dicts.append(dict(id=header["id"], type=header_type, info=info_dict)) |
1010 | 1017 |
|
| 1018 | + # Notify plugins the datastore will be updated |
| 1019 | + for plugin in plugins.PluginImplementations(interfaces.IDataPusher): |
| 1020 | + plugin.datastore_before_update( |
| 1021 | + resource_id=resource_id, |
| 1022 | + existing_info=existing_info, |
| 1023 | + new_headers=headers_dicts, |
| 1024 | + ) |
| 1025 | + |
1011 | 1026 | # Maintain data dictionaries from matching column names |
1012 | 1027 | # if data dictionary already exists for this resource as |
1013 | 1028 | # we want to preserve the user's data dictionary curations |
|
0 commit comments