From e84f532b9e97dc2ad53ad96cc9543a178d6f20fd Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 25 Sep 2018 12:41:41 +0200 Subject: gui: add input to RC page, improve predistortion page --- gui/api/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gui/api/__init__.py') diff --git a/gui/api/__init__.py b/gui/api/__init__.py index 74f5feb..cef81c6 100755 --- a/gui/api/__init__.py +++ b/gui/api/__init__.py @@ -33,7 +33,7 @@ import datetime def send_ok(data): return json.dumps({'status' : 'ok', 'data': data}).encode() -def send_error(data, reason=""): +def send_error(reason=""): return json.dumps({'status' : 'error', 'reason': reason}).encode() class API: @@ -72,7 +72,10 @@ class API: def trigger_capture(self, **kwargs): if cherrypy.request.method == 'POST': cherrypy.response.headers["Content-Type"] = "application/json" - return send_ok(self.dpd.capture_samples()) + try: + return send_ok(self.dpd.capture_samples()) + except ValueError as e: + return send_error(str(e)) else: cherrypy.response.headers["Content-Type"] = "application/json" cherrypy.response.status = 400 -- cgit v1.2.3