summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <ikj1234i@yahoo.com>2021-09-21 17:31:48 -0400
committerMax <ikj1234i@yahoo.com>2021-09-21 17:31:48 -0400
commit56daa99b94e47fd19e2dd0d8d8b9b0ec4a435c9c (patch)
tree80592462252598825edafcdeb2ae6accc3377468
parentf93460a0bd70c2e757b0cff4f794c07f57fd0fb4 (diff)
http_server bugfixes
-rwxr-xr-xop25/gr-op25_repeater/apps/http_server.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/op25/gr-op25_repeater/apps/http_server.py b/op25/gr-op25_repeater/apps/http_server.py
index ac3d88d..f402353 100755
--- a/op25/gr-op25_repeater/apps/http_server.py
+++ b/op25/gr-op25_repeater/apps/http_server.py
@@ -227,6 +227,12 @@ def post_req(environ, start_response, postdata):
traceback.print_exc(limit=None, file=sys.stderr)
sys.stderr.write('*** end traceback ***\n')
for d in data:
+ if type(d) is str:
+ sys.stderr.write('%f possible json sequence error: len %d type %s value %s\n' % (time.time(), len(d), type(d), d))
+ continue
+ elif type(d) is not dict:
+ sys.stderr.write('%f possible json sequence error: type %s value %s\n' % (time.time(), type(d), d))
+ continue
if d['command'].startswith('config-') or d['command'].startswith('rx-'):
resp = do_request(d)
if resp:
@@ -283,7 +289,16 @@ def application(environ, start_response):
except:
failed = True
sys.stderr.write('application: request failed:\n%s\n' % traceback.format_exc())
- sys.exit(1)
+ if failed:
+ status = '500 Internal Server Error'
+ response_headers = [ ('Access-Control-Allow-Origin', '*') ]
+ start_response(status, response_headers)
+ output = status
+ if sys.version[0] != '2':
+ if isinstance(output, str):
+ output = output.encode()
+ return [output]
+
return result
def process_qmsg(msg):