eodag 3.0.0b2__py3-none-any.whl → 3.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eodag/__init__.py +6 -8
- eodag/api/core.py +295 -287
- eodag/api/product/__init__.py +10 -4
- eodag/api/product/_assets.py +2 -14
- eodag/api/product/_product.py +16 -30
- eodag/api/product/drivers/__init__.py +7 -2
- eodag/api/product/drivers/base.py +0 -3
- eodag/api/product/metadata_mapping.py +12 -31
- eodag/api/search_result.py +33 -12
- eodag/cli.py +35 -19
- eodag/config.py +455 -155
- eodag/plugins/apis/base.py +13 -7
- eodag/plugins/apis/ecmwf.py +16 -7
- eodag/plugins/apis/usgs.py +68 -16
- eodag/plugins/authentication/aws_auth.py +25 -7
- eodag/plugins/authentication/base.py +10 -1
- eodag/plugins/authentication/generic.py +14 -3
- eodag/plugins/authentication/header.py +12 -4
- eodag/plugins/authentication/keycloak.py +41 -22
- eodag/plugins/authentication/oauth.py +11 -1
- eodag/plugins/authentication/openid_connect.py +183 -167
- eodag/plugins/authentication/qsauth.py +12 -4
- eodag/plugins/authentication/sas_auth.py +19 -2
- eodag/plugins/authentication/token.py +59 -11
- eodag/plugins/authentication/token_exchange.py +19 -19
- eodag/plugins/crunch/base.py +7 -2
- eodag/plugins/crunch/filter_date.py +8 -11
- eodag/plugins/crunch/filter_latest_intersect.py +5 -7
- eodag/plugins/crunch/filter_latest_tpl_name.py +2 -5
- eodag/plugins/crunch/filter_overlap.py +9 -15
- eodag/plugins/crunch/filter_property.py +9 -14
- eodag/plugins/download/aws.py +84 -99
- eodag/plugins/download/base.py +36 -77
- eodag/plugins/download/creodias_s3.py +11 -2
- eodag/plugins/download/http.py +134 -109
- eodag/plugins/download/s3rest.py +37 -43
- eodag/plugins/manager.py +173 -41
- eodag/plugins/search/__init__.py +9 -9
- eodag/plugins/search/base.py +35 -35
- eodag/plugins/search/build_search_result.py +55 -64
- eodag/plugins/search/cop_marine.py +113 -32
- eodag/plugins/search/creodias_s3.py +20 -8
- eodag/plugins/search/csw.py +41 -1
- eodag/plugins/search/data_request_search.py +119 -14
- eodag/plugins/search/qssearch.py +619 -197
- eodag/plugins/search/static_stac_search.py +25 -23
- eodag/resources/ext_product_types.json +1 -1
- eodag/resources/product_types.yml +211 -56
- eodag/resources/providers.yml +1762 -1809
- eodag/resources/stac.yml +3 -163
- eodag/resources/user_conf_template.yml +134 -119
- eodag/rest/config.py +1 -2
- eodag/rest/constants.py +0 -1
- eodag/rest/core.py +70 -92
- eodag/rest/errors.py +181 -0
- eodag/rest/server.py +24 -330
- eodag/rest/stac.py +105 -630
- eodag/rest/types/eodag_search.py +17 -15
- eodag/rest/types/queryables.py +5 -14
- eodag/rest/types/stac_search.py +18 -13
- eodag/rest/utils/rfc3339.py +0 -1
- eodag/types/__init__.py +24 -6
- eodag/types/download_args.py +14 -5
- eodag/types/queryables.py +1 -2
- eodag/types/search_args.py +10 -11
- eodag/types/whoosh.py +0 -2
- eodag/utils/__init__.py +97 -136
- eodag/utils/constraints.py +0 -8
- eodag/utils/exceptions.py +23 -9
- eodag/utils/import_system.py +0 -4
- eodag/utils/logging.py +37 -80
- eodag/utils/notebook.py +4 -4
- eodag/utils/requests.py +13 -23
- eodag/utils/rest.py +0 -4
- eodag/utils/stac_reader.py +3 -15
- {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/METADATA +41 -24
- eodag-3.0.1.dist-info/RECORD +109 -0
- {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/WHEEL +1 -1
- {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/entry_points.txt +1 -0
- eodag/resources/constraints/climate-dt.json +0 -13
- eodag/resources/constraints/extremes-dt.json +0 -8
- eodag-3.0.0b2.dist-info/RECORD +0 -110
- {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/LICENSE +0 -0
- {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/top_level.txt +0 -0
|
@@ -29,7 +29,12 @@ from eodag.config import PluginConfig
|
|
|
29
29
|
from eodag.plugins.authentication.aws_auth import AwsAuth
|
|
30
30
|
from eodag.plugins.search.qssearch import ODataV4Search
|
|
31
31
|
from eodag.utils import guess_file_type
|
|
32
|
-
from eodag.utils.exceptions import
|
|
32
|
+
from eodag.utils.exceptions import (
|
|
33
|
+
AuthenticationError,
|
|
34
|
+
MisconfiguredError,
|
|
35
|
+
NotAvailableError,
|
|
36
|
+
RequestError,
|
|
37
|
+
)
|
|
33
38
|
|
|
34
39
|
DATA_EXTENSIONS = ["jp2", "tiff", "nc", "grib"]
|
|
35
40
|
logger = logging.getLogger("eodag.search.creodiass3")
|
|
@@ -38,13 +43,10 @@ logger = logging.getLogger("eodag.search.creodiass3")
|
|
|
38
43
|
def patched_register_downloader(self, downloader, authenticator):
|
|
39
44
|
"""Add the download information to the product.
|
|
40
45
|
:param self: product to which information should be added
|
|
41
|
-
:type self: EoProduct
|
|
42
46
|
:param downloader: The download method that it can use
|
|
43
|
-
:type downloader: Concrete subclass of
|
|
44
47
|
:class:`~eodag.plugins.download.base.Download` or
|
|
45
48
|
:class:`~eodag.plugins.api.base.Api`
|
|
46
49
|
:param authenticator: The authentication method needed to perform the download
|
|
47
|
-
:type authenticator: Concrete subclass of
|
|
48
50
|
:class:`~eodag.plugins.authentication.base.Authentication`
|
|
49
51
|
"""
|
|
50
52
|
# register downloader
|
|
@@ -53,7 +55,7 @@ def patched_register_downloader(self, downloader, authenticator):
|
|
|
53
55
|
try:
|
|
54
56
|
_update_assets(self, downloader.config, authenticator)
|
|
55
57
|
except BotoCoreError as e:
|
|
56
|
-
raise RequestError(
|
|
58
|
+
raise RequestError.from_error(e, "could not update assets") from e
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
def _update_assets(product: EOProduct, config: PluginConfig, auth: AwsAuth):
|
|
@@ -73,7 +75,7 @@ def _update_assets(product: EOProduct, config: PluginConfig, auth: AwsAuth):
|
|
|
73
75
|
if not getattr(auth, "s3_client", None):
|
|
74
76
|
auth.s3_client = boto3.client(
|
|
75
77
|
"s3",
|
|
76
|
-
endpoint_url=config.
|
|
78
|
+
endpoint_url=config.s3_endpoint,
|
|
77
79
|
aws_access_key_id=auth_dict["aws_access_key_id"],
|
|
78
80
|
aws_secret_access_key=auth_dict["aws_secret_access_key"],
|
|
79
81
|
)
|
|
@@ -108,12 +110,22 @@ def _update_assets(product: EOProduct, config: PluginConfig, auth: AwsAuth):
|
|
|
108
110
|
raise AuthenticationError(
|
|
109
111
|
f"Authentication failed on {config.base_uri} s3"
|
|
110
112
|
) from e
|
|
111
|
-
raise
|
|
113
|
+
raise NotAvailableError(
|
|
114
|
+
f"assets for product {prefix} could not be found"
|
|
115
|
+
) from e
|
|
112
116
|
|
|
113
117
|
|
|
114
118
|
class CreodiasS3Search(ODataV4Search):
|
|
115
119
|
"""
|
|
116
|
-
|
|
120
|
+
``CreodiasS3Search`` is an extension of :class:`~eodag.plugins.search.qssearch.ODataV4Search`,
|
|
121
|
+
it executes a Search on creodias and adapts results so that the assets contain links to s3.
|
|
122
|
+
It has the same configuration parameters as :class:`~eodag.plugins.search.qssearch.ODataV4Search` and
|
|
123
|
+
one additional parameter:
|
|
124
|
+
|
|
125
|
+
:param provider: provider name
|
|
126
|
+
:param config: Search plugin configuration:
|
|
127
|
+
|
|
128
|
+
* :attr:`~eodag.config.PluginConfig.s3_endpoint` (``str``) (**mandatory**): base url of the s3
|
|
117
129
|
"""
|
|
118
130
|
|
|
119
131
|
def __init__(self, provider, config):
|
eodag/plugins/search/csw.py
CHANGED
|
@@ -52,7 +52,47 @@ SUPPORTED_REFERENCE_SCHEMES = ["WWW:DOWNLOAD-1.0-http--download"]
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
class CSWSearch(Search):
|
|
55
|
-
"""A plugin for implementing search based on OGC CSW
|
|
55
|
+
"""A plugin for implementing search based on OGC CSW
|
|
56
|
+
|
|
57
|
+
:param provider: provider name
|
|
58
|
+
:param config: Search plugin configuration:
|
|
59
|
+
|
|
60
|
+
* :attr:`~eodag.config.PluginConfig.api_endpoint` (``str``) (**mandatory**): The endpoint of the
|
|
61
|
+
provider's search interface
|
|
62
|
+
* :attr:`~eodag.config.PluginConfig.version` (``str``): OGC Catalogue Service version; default: ``2.0.2``
|
|
63
|
+
* :attr:`~eodag.config.PluginConfig.search_definition` (``Dict[str, Any]``) (**mandatory**):
|
|
64
|
+
|
|
65
|
+
* **product_type_tags** (``List[Dict[str, Any]``): dict of product type tags
|
|
66
|
+
* **resource_location_filter** (``str``): regex string
|
|
67
|
+
* **date_tags** (``Dict[str, Any]``): tags for start and end
|
|
68
|
+
|
|
69
|
+
* :attr:`~eodag.config.PluginConfig.metadata_mapping` (``Dict[str, Any]``): The search plugins of this kind can
|
|
70
|
+
detect when a metadata mapping is "query-able", and get the semantics of how to format the query string
|
|
71
|
+
parameter that enables to make a query on the corresponding metadata. To make a metadata query-able,
|
|
72
|
+
just configure it in the metadata mapping to be a list of 2 items, the first one being the
|
|
73
|
+
specification of the query string search formatting. The later is a string following the
|
|
74
|
+
specification of Python string formatting, with a special behaviour added to it. For example,
|
|
75
|
+
an entry in the metadata mapping of this kind::
|
|
76
|
+
|
|
77
|
+
completionTimeFromAscendingNode:
|
|
78
|
+
- 'f=acquisition.endViewingDate:lte:{completionTimeFromAscendingNode#timestamp}'
|
|
79
|
+
- '$.properties.acquisition.endViewingDate'
|
|
80
|
+
|
|
81
|
+
means that the search url will have a query string parameter named ``f`` with a value of
|
|
82
|
+
``acquisition.endViewingDate:lte:1543922280.0`` if the search was done with the value
|
|
83
|
+
of ``completionTimeFromAscendingNode`` being ``2018-12-04T12:18:00``. What happened is that
|
|
84
|
+
``{completionTimeFromAscendingNode#timestamp}`` was replaced with the timestamp of the value
|
|
85
|
+
of ``completionTimeFromAscendingNode``. This example shows all there is to know about the
|
|
86
|
+
semantics of the query string formatting introduced by this plugin: any eodag search parameter
|
|
87
|
+
can be referenced in the query string with an additional optional conversion function that
|
|
88
|
+
is separated from it by a ``#`` (see :func:`~eodag.api.product.metadata_mapping.format_metadata` for further
|
|
89
|
+
details on the available converters). Note that for the values in the
|
|
90
|
+
:attr:`~eodag.config.PluginConfig.free_text_search_operations` configuration parameter follow the same rule.
|
|
91
|
+
If the metadata_mapping is not a list but only a string, this means that the parameters is not queryable but
|
|
92
|
+
it is included in the result obtained from the provider. The string indicates how the provider result should
|
|
93
|
+
be mapped to the eodag parameter.
|
|
94
|
+
|
|
95
|
+
"""
|
|
56
96
|
|
|
57
97
|
def __init__(self, provider: str, config: PluginConfig) -> None:
|
|
58
98
|
super(CSWSearch, self).__init__(provider, config)
|
|
@@ -58,9 +58,107 @@ logger = logging.getLogger("eodag.search.data_request_search")
|
|
|
58
58
|
class DataRequestSearch(Search):
|
|
59
59
|
"""
|
|
60
60
|
Plugin to execute search requests composed of several steps:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
|
|
62
|
+
#. do a data request which defines which data shall be searched
|
|
63
|
+
#. check the status of the request job
|
|
64
|
+
#. if finished - fetch the result of the job
|
|
65
|
+
|
|
66
|
+
:param provider: provider name
|
|
67
|
+
:param config: Search plugin configuration:
|
|
68
|
+
|
|
69
|
+
* :attr:`~eodag.config.PluginConfig.api_endpoint` (``str``) (**mandatory**): The endpoint of the
|
|
70
|
+
provider's search interface
|
|
71
|
+
* :attr:`~eodag.config.PluginConfig.results_entry` (``str``) (**mandatory**): The name of
|
|
72
|
+
the key in the provider search result that gives access to the result entries
|
|
73
|
+
* :attr:`~eodag.config.PluginConfig.data_request_url` (``str``) (**mandatory**): url
|
|
74
|
+
to which the data request shall be sent
|
|
75
|
+
* :attr:`~eodag.config.PluginConfig.status_url` (``str``) (**mandatory**): url to fetch
|
|
76
|
+
the status of the data request
|
|
77
|
+
* :attr:`~eodag.config.PluginConfig.result_url` (``str``) (**mandatory**): url to fetch
|
|
78
|
+
the search result when the data request is done
|
|
79
|
+
* :attr:`~eodag.config.PluginConfig.need_auth` (``bool``): if authentication is needed for
|
|
80
|
+
the search request; default: ``False``
|
|
81
|
+
* :attr:`~eodag.config.PluginConfig.auth_error_code` (``int``): which error code is returned in case of an
|
|
82
|
+
authentication error; only used if ``need_auth=true``
|
|
83
|
+
* :attr:`~eodag.config.PluginConfig.ssl_verify` (``bool``): if the ssl certificates should be
|
|
84
|
+
verified in requests; default: ``True``
|
|
85
|
+
* :attr:`~eodag.config.PluginConfig.timeout` (``int``): time to wait until request timeout in seconds;
|
|
86
|
+
default: ``5``
|
|
87
|
+
* :attr:`~eodag.config.PluginConfig.dates_required` (``bool``): if date parameters are mandatory
|
|
88
|
+
in the request; default: ``True``
|
|
89
|
+
* :attr:`~eodag.config.PluginConfig.pagination` (:class:`~eodag.config.PluginConfig.Pagination`)
|
|
90
|
+
(**mandatory**): The configuration of how the pagination is done on the provider. It is a tree with the
|
|
91
|
+
following nodes:
|
|
92
|
+
|
|
93
|
+
* :attr:`~eodag.config.PluginConfig.Pagination.total_items_nb_key_path` (``str``): An XPath or JsonPath
|
|
94
|
+
leading to the total number of results satisfying a request. This is used for providers which provides the
|
|
95
|
+
total results metadata along with the result of the query and don't have an endpoint for querying
|
|
96
|
+
the number of items satisfying a request, or for providers for which the count endpoint
|
|
97
|
+
returns a json or xml document
|
|
98
|
+
* :attr:`~eodag.config.PluginConfig.Pagination.max_items_per_page` (``int``): The maximum
|
|
99
|
+
number of items per page that the provider can handle; default: ``50``
|
|
100
|
+
* :attr:`~eodag.config.PluginConfig.Pagination.start_page` (``int``): number of the
|
|
101
|
+
first page; default: ``1``
|
|
102
|
+
|
|
103
|
+
* :attr:`~eodag.config.PluginConfig.discover_product_types`
|
|
104
|
+
(:class:`~eodag.config.PluginConfig.DiscoverProductTypes`): configuration for product type discovery based on
|
|
105
|
+
information from the provider; It contains the keys:
|
|
106
|
+
|
|
107
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.fetch_url` (``str``) (**mandatory**): url from which
|
|
108
|
+
the product types can be fetched
|
|
109
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.result_type` (``str``): type of the provider result;
|
|
110
|
+
currently only ``json`` is supported (other types could be used in an extension of this plugin)
|
|
111
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.results_entry` (``str``) (**mandatory**): json path
|
|
112
|
+
to the list of product types
|
|
113
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.generic_product_type_id` (``str``): mapping for the
|
|
114
|
+
product type id
|
|
115
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.generic_product_type_parsable_metadata`
|
|
116
|
+
(``Dict[str, str]``): mapping for product type metadata (e.g. ``abstract``, ``licence``) which can be parsed
|
|
117
|
+
from the provider result
|
|
118
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.generic_product_type_parsable_properties`
|
|
119
|
+
(``Dict[str, str]``): mapping for product type properties which can be parsed from the result that are not
|
|
120
|
+
product type metadata
|
|
121
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.single_collection_fetch_url` (``str``): url to fetch
|
|
122
|
+
data for a single collection; used if product type metadata is not available from the endpoint given in
|
|
123
|
+
:attr:`~eodag.config.PluginConfig.DiscoverProductTypes.fetch_url`
|
|
124
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.single_collection_fetch_qs` (``str``): query string
|
|
125
|
+
to be added to the :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.fetch_url` to filter for a
|
|
126
|
+
collection
|
|
127
|
+
* :attr:`~eodag.config.PluginConfig.DiscoverProductTypes.single_product_type_parsable_metadata`
|
|
128
|
+
(``Dict[str, str]``): mapping for product type metadata returned by the endpoint given in
|
|
129
|
+
:attr:`~eodag.config.PluginConfig.DiscoverProductTypes.single_collection_fetch_url`.
|
|
130
|
+
|
|
131
|
+
* :attr:`~eodag.config.PluginConfig.constraints_file_url` (``str``): url to fetch the constraints for a specific
|
|
132
|
+
product type, can be an http url or a path to a file; the constraints are used to build queryables
|
|
133
|
+
* :attr:`~eodag.config.PluginConfig.constraints_entry` (``str``): key in the json result where the constraints
|
|
134
|
+
can be found; if not given, it is assumed that the constraints are on top level of the result, i.e.
|
|
135
|
+
the result is an array of constraints
|
|
136
|
+
* :attr:`~eodag.config.PluginConfig.metadata_mapping` (``Dict[str, Any]``): The search plugins of this kind can
|
|
137
|
+
detect when a metadata mapping is "query-able", and get the semantics of how to format the query string
|
|
138
|
+
parameter that enables to make a query on the corresponding metadata. To make a metadata query-able,
|
|
139
|
+
just configure it in the metadata mapping to be a list of 2 items, the first one being the
|
|
140
|
+
specification of the query string search formatting. The later is a string following the
|
|
141
|
+
specification of Python string formatting, with a special behaviour added to it. For example,
|
|
142
|
+
an entry in the metadata mapping of this kind::
|
|
143
|
+
|
|
144
|
+
completionTimeFromAscendingNode:
|
|
145
|
+
- 'f=acquisition.endViewingDate:lte:{completionTimeFromAscendingNode#timestamp}'
|
|
146
|
+
- '$.properties.acquisition.endViewingDate'
|
|
147
|
+
|
|
148
|
+
means that the search url will have a query string parameter named ``f`` with a value of
|
|
149
|
+
``acquisition.endViewingDate:lte:1543922280.0`` if the search was done with the value
|
|
150
|
+
of ``completionTimeFromAscendingNode`` being ``2018-12-04T12:18:00``. What happened is that
|
|
151
|
+
``{completionTimeFromAscendingNode#timestamp}`` was replaced with the timestamp of the value
|
|
152
|
+
of ``completionTimeFromAscendingNode``. This example shows all there is to know about the
|
|
153
|
+
semantics of the query string formatting introduced by this plugin: any eodag search parameter
|
|
154
|
+
can be referenced in the query string with an additional optional conversion function that
|
|
155
|
+
is separated from it by a ``#`` (see :func:`~eodag.api.product.metadata_mapping.format_metadata` for further
|
|
156
|
+
details on the available converters). Note that for the values in the
|
|
157
|
+
:attr:`~eodag.config.PluginConfig.free_text_search_operations` configuration parameter follow the same rule.
|
|
158
|
+
If the metadata_mapping is not a list but only a string, this means that the parameters is not queryable but
|
|
159
|
+
it is included in the result obtained from the provider. The string indicates how the provider result should
|
|
160
|
+
be mapped to the eodag parameter.
|
|
161
|
+
|
|
64
162
|
"""
|
|
65
163
|
|
|
66
164
|
data_request_id: Optional[str]
|
|
@@ -116,7 +214,6 @@ class DataRequestSearch(Search):
|
|
|
116
214
|
"""Fetch product types is disabled for `DataRequestSearch`
|
|
117
215
|
|
|
118
216
|
:returns: empty dict
|
|
119
|
-
:rtype: (optional) dict
|
|
120
217
|
"""
|
|
121
218
|
return None
|
|
122
219
|
|
|
@@ -133,7 +230,7 @@ class DataRequestSearch(Search):
|
|
|
133
230
|
"""
|
|
134
231
|
performs the search for a provider where several steps are required to fetch the data
|
|
135
232
|
"""
|
|
136
|
-
if kwargs.get("
|
|
233
|
+
if kwargs.get("sort_by"):
|
|
137
234
|
raise ValidationError(f"{self.provider} does not support sorting feature")
|
|
138
235
|
|
|
139
236
|
product_type = kwargs.get("productType", None)
|
|
@@ -276,9 +373,9 @@ class DataRequestSearch(Search):
|
|
|
276
373
|
except requests.exceptions.Timeout as exc:
|
|
277
374
|
raise TimeOutError(exc, timeout=HTTP_REQ_TIMEOUT) from exc
|
|
278
375
|
except requests.RequestException as e:
|
|
279
|
-
raise RequestError(
|
|
280
|
-
f"search job for product_type {product_type} could not be created
|
|
281
|
-
)
|
|
376
|
+
raise RequestError.from_error(
|
|
377
|
+
e, f"search job for product_type {product_type} could not be created"
|
|
378
|
+
) from e
|
|
282
379
|
else:
|
|
283
380
|
logger.info("search job for product_type %s created", product_type)
|
|
284
381
|
return request_job.json()["jobId"]
|
|
@@ -295,7 +392,7 @@ class DataRequestSearch(Search):
|
|
|
295
392
|
except requests.exceptions.Timeout as exc:
|
|
296
393
|
raise TimeOutError(exc, timeout=HTTP_REQ_TIMEOUT) from exc
|
|
297
394
|
except requests.RequestException as e:
|
|
298
|
-
raise RequestError(
|
|
395
|
+
raise RequestError.from_error(e, "_cancel_request failed") from e
|
|
299
396
|
|
|
300
397
|
def _check_request_status(self, data_request_id: str) -> bool:
|
|
301
398
|
logger.debug("checking status of request job %s", data_request_id)
|
|
@@ -314,7 +411,7 @@ class DataRequestSearch(Search):
|
|
|
314
411
|
except requests.exceptions.Timeout as exc:
|
|
315
412
|
raise TimeOutError(exc, timeout=HTTP_REQ_TIMEOUT) from exc
|
|
316
413
|
except requests.RequestException as e:
|
|
317
|
-
raise RequestError(
|
|
414
|
+
raise RequestError.from_error(e, "_check_request_status failed") from e
|
|
318
415
|
else:
|
|
319
416
|
status_data = status_resp.json()
|
|
320
417
|
if "status_code" in status_data and status_data["status_code"] in [
|
|
@@ -322,7 +419,9 @@ class DataRequestSearch(Search):
|
|
|
322
419
|
404,
|
|
323
420
|
]:
|
|
324
421
|
logger.error(f"_check_request_status failed: {status_data}")
|
|
325
|
-
|
|
422
|
+
error = RequestError("authentication token expired during request")
|
|
423
|
+
error.status_code = status_data["status_code"]
|
|
424
|
+
raise error
|
|
326
425
|
if status_data["status"] == "failed":
|
|
327
426
|
logger.error(f"_check_request_status failed: {status_data}")
|
|
328
427
|
raise RequestError(
|
|
@@ -386,8 +485,11 @@ class DataRequestSearch(Search):
|
|
|
386
485
|
total_items_nb_key_path = string_to_jsonpath(
|
|
387
486
|
self.config.pagination["total_items_nb_key_path"]
|
|
388
487
|
)
|
|
389
|
-
|
|
390
|
-
|
|
488
|
+
found_total_items_nb_paths = total_items_nb_key_path.find(results)
|
|
489
|
+
if found_total_items_nb_paths and not isinstance(
|
|
490
|
+
found_total_items_nb_paths, int
|
|
491
|
+
):
|
|
492
|
+
total_items_nb = found_total_items_nb_paths[0].value
|
|
391
493
|
else:
|
|
392
494
|
total_items_nb = 0
|
|
393
495
|
for p in products:
|
|
@@ -423,7 +525,10 @@ class DataRequestSearch(Search):
|
|
|
423
525
|
path = string_to_jsonpath(custom_filters["filter_attribute"])
|
|
424
526
|
indexes = custom_filters["indexes"].split("-")
|
|
425
527
|
for record in results:
|
|
426
|
-
|
|
528
|
+
found_paths = path.find(record)
|
|
529
|
+
if not found_paths or isinstance(found_paths, int):
|
|
530
|
+
continue
|
|
531
|
+
filter_param = found_paths[0].value
|
|
427
532
|
filter_value = filter_param[int(indexes[0]) : int(indexes[1])]
|
|
428
533
|
filter_clause = "'" + filter_value + "' " + custom_filters["filter_clause"]
|
|
429
534
|
if eval(filter_clause):
|