From 9595bfae52f17f95449db20249382bf315f56c86 Mon Sep 17 00:00:00 2001 From: david-i-berry Date: Fri, 7 Jul 2023 12:10:15 +0200 Subject: [PATCH] debugging result. --- synop2bufr/pygeoapi_plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/synop2bufr/pygeoapi_plugin.py b/synop2bufr/pygeoapi_plugin.py index bc05a83..73170eb 100644 --- a/synop2bufr/pygeoapi_plugin.py +++ b/synop2bufr/pygeoapi_plugin.py @@ -19,6 +19,7 @@ # ############################################################################### import base64 +import json import logging from pygeoapi.process.base import BaseProcessor @@ -89,7 +90,7 @@ }, "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 + "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", #noqa "year": 2022, "month": 2 @@ -133,7 +134,11 @@ def execute(self, data): # and add to single output object for result in bufr_generator: + # need to convert BUFR binary to base64 result['bufr4'] = base64.b64encode( result['bufr4'] ).decode("utf-8") # noqa + # convert datetime to string + result['_meta']['properties']['datetime'] = \ + result['_meta']['properties']['datetime'].isoformat() bufr.append(result) except Exception as e: @@ -142,8 +147,6 @@ def execute(self, data): output = {"result": json.dumps(bufr), "errors": json.dumps(errors)} - - LOGGER.error("returning") return mimetype, output def __repr__(self):