From 5c21dec7717ba4038d6f5bf81f2ac95abac5a2cb Mon Sep 17 00:00:00 2001 From: david-i-berry Date: Fri, 7 Jul 2023 11:54:47 +0200 Subject: [PATCH] debugging result. --- synop2bufr/pygeoapi_plugin.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/synop2bufr/pygeoapi_plugin.py b/synop2bufr/pygeoapi_plugin.py index 0f97565..0064ac5 100644 --- a/synop2bufr/pygeoapi_plugin.py +++ b/synop2bufr/pygeoapi_plugin.py @@ -78,20 +78,23 @@ } }, "outputs": { - "messages": { + "result": { "title": "BUFR encoded data in base64", # noqa - "schema": {"type": "array"}, - "description": "One result per line in input data" # noqa + "schema": {"contentMediaType": "application/json"} + }, + "errors": { + "title": "Errors", + "schema": {"contentMediaType": "application/json"} } }, "example": { "inputs": { "data":r"AAXX 21121 15015 02999 02501 10103 21090 39765 42952 57020 60001 333 4/000 55310 0//// 22591 3//// 60007 91003 91104=", # noqa - "metadata": r"station_name,wigos_station_identifier,traditional_station_identifier,facility_type,latitude,longitude,elevation,territory_name,wmo_region\\nOCNA SUGATAG,0-20000-0-15015,15015,Land (fixed),47.77706163,23.94046026,503,Romania,6", + "metadata": r"station_name,wigos_station_identifier,traditional_station_identifier,facility_type,latitude,longitude,elevation,territory_name,wmo_region\\nOCNA SUGATAG,0-20000-0-15015,15015,Land (fixed),47.77706163,23.94046026,503,Romania,6", #noqa "year": 2022, "month": 2 }, - "output": {"messages": []} + "output": {} }, } @@ -132,11 +135,13 @@ def execute(self, data): for result in bufr_generator: result['bufr4'] = base64.b64encode( result['bufr4'] ).decode("utf-8") # noqa bufr.append(result) - output = {"messages": bufr, "errors": errors} + except Exception as e: LOGGER.error(e) errors.append(f"{e}") - output = {"messages": bufr, "errors": errors} + + output = {"result": json.dumps(result), "errors": json.dumps(errors)} + LOGGER.error("returning") return mimetype, output