diff options
author | coderick14 | 2017-06-25 19:47:04 +0530 |
---|---|---|
committer | coderick14 | 2017-06-25 19:47:04 +0530 |
commit | eae6f7d4d39cbff77fc0785be47d5735c1ceb2c4 (patch) | |
tree | 95cdcff2341cfd730fe2ff1f9af9baca8e71c326 | |
parent | f67527fe88cd33cb1b031a05e5743f1d174b68fe (diff) | |
download | SBHS-2018-Rpi-eae6f7d4d39cbff77fc0785be47d5735c1ceb2c4.tar.gz SBHS-2018-Rpi-eae6f7d4d39cbff77fc0785be47d5735c1ceb2c4.tar.bz2 SBHS-2018-Rpi-eae6f7d4d39cbff77fc0785be47d5735c1ceb2c4.zip |
Catch key not found Exception in pi_ip_map
-rw-r--r-- | experiment/views.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/experiment/views.py b/experiment/views.py index c2424a1..20173fd 100644 --- a/experiment/views.py +++ b/experiment/views.py @@ -29,7 +29,9 @@ def initial_login(req): except Exception as e: return HttpResponse(json.dumps({"STATUS": 400, "MESSAGE": {"IS_IP":"1","DATA":"Invalid username"}})) - rpi_ip = settings.pi_ip_map[str(assigned_mid)] + rpi_ip = settings.pi_ip_map.get(str(assigned_mid)) + if rpi_ip is None: + return HttpResponse(json.dumps({"STATUS": 400, "MESSAGE": {"IS_IP": "1", "DATA":"Board is currently offline"}})) return HttpResponse(json.dumps({"STATUS": 200, "MESSAGE": {"IS_IP":"1","DATA":rpi_ip}})) # return HttpResponse(key) |