]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/result_formatter/v1.py
convert version to named tuple
[nominatim.git] / nominatim / result_formatter / v1.py
index d14e3f6c4105209faf387f0446a14bc2f4a981a2..1d437af7ed667a92247088c35cb316faa3b86874 100644 (file)
@@ -18,19 +18,21 @@ create = FormatDispatcher()
 
 @create.format_func(StatusResult, 'text')
 def _format_status_text(result: StatusResult) -> str:
-    return result.message
+    if result.status:
+        return f"ERROR: {result.message}"
+
+    return 'OK'
 
 
 @create.format_func(StatusResult, 'json')
 def _format_status_json(result: StatusResult) -> str:
-    # XXX write a simple JSON serializer
     out: Dict[str, Any] = OrderedDict()
     out['status'] = result.status
     out['message'] = result.message
     if result.data_updated is not None:
-        out['data_updated'] = result.data_updated
-    out['software_version'] = result.software_version
+        out['data_updated'] = result.data_updated.isoformat()
+    out['software_version'] = str(result.software_version)
     if result.database_version is not None:
-        out['database_version'] = result.database_version
+        out['database_version'] = str(result.database_version)
 
     return json.dumps(out)