diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-01-09 15:44:06 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-01-09 15:44:06 +0100 |
commit | b717160a90279c21c068d39673c6aafad66dfcae (patch) | |
tree | 01aaf768ebae270cd5f58261d777b374ee1152e6 /python/gui/api.py | |
parent | 75ba4f064a65ebad77d130f160b9469418e49c9f (diff) | |
download | dabmod-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-x | python/gui/api.py | 20 |
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() |