diff --git a/PythonServer/pos-python-server.py b/PythonServer/pos-python-server.py index 146cf235eea276dd3c284ae402c3c39f3ad65559..8ab6b1c8237974f0349403f662d3d66d2d46603d 100755 --- a/PythonServer/pos-python-server.py +++ b/PythonServer/pos-python-server.py @@ -3,6 +3,7 @@ import uvicorn import epics import time import requests +import json from fastapi import FastAPI from fastapi.responses import PlainTextResponse import dateutil.parser @@ -42,8 +43,11 @@ def get_pv(pvlist: str): pvs = [epics.get_pv(pvname, auto_monitor=True) for pvname in pvnames] time.sleep(1) result = {p.pvname: p._args for p in pvs} - for pv in pvs: + if hasattr(result[pv.pvname]["chid"], "value"): + result[pv.pvname]["chid"] = result[pv.pvname]["chid"].value + if result[pv.pvname]["char_value"] == "[]": + result[pv.pvname]["value"] = [] if ( result[pv.pvname]["count"] is not None and result[pv.pvname]["value"] is not None @@ -51,7 +55,8 @@ def get_pv(pvlist: str): and type(result[pv.pvname]["value"]) != list ): result[pv.pvname]["value"] = result[pv.pvname]["value"].tolist() - return result + + return json.loads(json.dumps(result)) @app.get("/api/v1/archiver/{pv}")