summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordk-152017-06-15 18:56:31 +0530
committerdk-152017-06-15 19:02:21 +0530
commiteafb39a96d85cd97429532fc7de9bff304618a59 (patch)
treed350897c3f4ace98b3491d14d8b392bb619bfdc7
parent730a85cddf9958e0e7c70bde0aebb0a566dc685c (diff)
downloadSBHS-2018-Rpi-eafb39a96d85cd97429532fc7de9bff304618a59.tar.gz
SBHS-2018-Rpi-eafb39a96d85cd97429532fc7de9bff304618a59.tar.bz2
SBHS-2018-Rpi-eafb39a96d85cd97429532fc7de9bff304618a59.zip
Update settings for new architecture
- Add Local IP to allowed host - Change database to mysql - Change Base URL to port 80 to work with apache - Add code to fetch online mids and pi_ip_map
-rw-r--r--sbhs_server/settings.py32
1 files changed, 10 insertions, 22 deletions
diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py
index 3625fc1..4e9873f 100644
--- a/sbhs_server/settings.py
+++ b/sbhs_server/settings.py
@@ -8,7 +8,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
import sys #srikant
-import socket
+import socket,json
import sbhs_server.credentials as credentials
@@ -37,6 +37,7 @@ ALLOWED_HOSTS = [
"127.0.0.1",
"192.168.43.208",
"192.168.43.144",
+ "10.42.0.1",
]
if not DEBUG:
@@ -94,7 +95,7 @@ WSGI_APPLICATION = 'sbhs_server.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
-if is_production:
+if not is_production:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
@@ -149,7 +150,7 @@ if is_production:
FORCE_SCRIPT_NAME = "/sbhs"
USE_X_FORWARDED_HOST = True
else:
- BASE_URL = "http://127.0.0.1:8000/"
+ BASE_URL = "http://127.0.0.1/"
SBHSCLIENT_STATIC_DIR = os.path.join(BASE_DIR, "client_static")
STATICFILES_DIRS = (
@@ -248,25 +249,12 @@ else:
SBHS_GLOBAL_LOG_DIR = os.path.join(BASE_DIR, 'log')
-from sbhs_server import sbhs
-boards = {}
-MID_PORT_MAP={}
-with open(os.path.join(BASE_DIR, 'map_machine_ids.txt')) as f:
- for line in f:
- try:
- data = line.split("=")
- brd = sbhs.Sbhs()
- b = brd.connect(int(data[0]))
- assert b == True
- key = int(brd.getMachineId())
- assert key > 0
- brd.reset_board()
- MID_PORT_MAP[key]=data[1].strip()
- boards[str(key)] = {"board": brd, "experiment_id": None}
- except:
- pass
-
-online_mids = [int(i) for i in boards.keys()]
+with open(os.path.join(BASE_DIR, "sbhs_server/pi-ip.json"),'r') as fh:
+ json_data = fh.read()
+
+pi_ip_map = json.loads(json_data)
+
+online_mids = list(pi_ip_map.keys())
print "No of machines online : ", len(online_mids)