summaryrefslogtreecommitdiffstats
path: root/python/gui/api.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-09 15:44:06 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-01-09 15:44:06 +0100
commitb717160a90279c21c068d39673c6aafad66dfcae (patch)
tree01aaf768ebae270cd5f58261d777b374ee1152e6 /python/gui/api.py
parent75ba4f064a65ebad77d130f160b9469418e49c9f (diff)
downloaddabmod-b717160a90279c21c068d39673c6aafad66dfcae.tar.gz
dabmod-b717160a90279c21c068d39673c6aafad66dfcae.tar.bz2
dabmod-b717160a90279c21c068d39673c6aafad66dfcae.zip
GUI: Add status to home page
Diffstat (limited to 'python/gui/api.py')
-rwxr-xr-xpython/gui/api.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/python/gui/api.py b/python/gui/api.py
index c0effde..f9e0ad0 100755
--- a/python/gui/api.py
+++ b/python/gui/api.py
@@ -80,8 +80,18 @@ class API:
return send_error(str(e))
return send_ok()
else:
- cherrypy.response.status = 400
- return send_error("POST only")
+ if all(p in kwargs for p in ('controllable', 'param')):
+ try:
+ return send_ok(self.mod_rc.get_param_value(kwargs['controllable'], kwargs['param']))
+ except IOError as e:
+ cherrypy.response.status = 503
+ return send_error(str(e))
+ except ValueError as e:
+ cherrypy.response.status = 503
+ return send_error(str(e))
+ else:
+ cherrypy.response.status = 400
+ return send_error("missing 'controllable' or 'param' GET parameters")
def _wrap_dpd(self, method, data=None):
try:
@@ -89,12 +99,12 @@ class API:
return send_ok(reply)
except ValueError as e:
cherrypy.response.status = 503
- return send_error("YAML-RPC call error: {}".format(e))
+ return send_error("DPDCE remote procedure call error: {}".format(e))
except TimeoutError as e:
cherrypy.response.status = 503
- return send_error("YAML-RPC timeout: {}".format(e))
+ return send_error("DPDCE remote procedure call timed out")
cherrypy.response.status = 500
- return send_error("YAML-RPC unknown error")
+ return send_error("Unknown DPDCE remote procedure error error")
@cherrypy.expose
@cherrypy.tools.json_out()