diff options
author | ttt | 2017-05-13 00:29:47 +0530 |
---|---|---|
committer | ttt | 2017-05-13 00:29:47 +0530 |
commit | abf599be33b383a6a5baf9493093b2126a622ac8 (patch) | |
tree | 4c5ab6e0d935d5e65fabcf0258e4a00dd20a5afa /sbhs_server/settings.py | |
download | SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.tar.gz SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.tar.bz2 SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.zip |
added all server files
Diffstat (limited to 'sbhs_server/settings.py')
-rw-r--r-- | sbhs_server/settings.py | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/sbhs_server/settings.py b/sbhs_server/settings.py new file mode 100644 index 0000000..30a0f81 --- /dev/null +++ b/sbhs_server/settings.py @@ -0,0 +1,241 @@ +""" +Django settings for sbhs_server project. + +For more information on this file, see +https://docs.djangoproject.com/en/1.6/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.6/ref/settings/ +""" +import sys #srikant +import socket +hostname = socket.gethostname() +is_production = hostname == "vlabs-Veriton-Series" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = is_production + +TEMPLATE_DEBUG = not is_production + +ALLOWED_HOSTS = [] + +if not DEBUG: + ALLOWED_HOSTS = [ + "localhost", + "127.0.0.1", + "vlabs.iitb.ac.in", + "vlabs.iitb.ac.in.", + "10.102.152.15", + ] + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + #'south', + 'undelete', + 'yaksh', + 'taggit', + + 'sbhs_server.account', + 'sbhs_server.admin', + 'sbhs_server.experiment', + 'sbhs_server.pages', + 'sbhs_server.password', + 'sbhs_server.slot', + 'sbhs_server.tables', + 'sbhs_server.webcam', +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = 'sbhs_server.urls' + +WSGI_APPLICATION = 'sbhs_server.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.6/ref/settings/#databases + +if is_production: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'database_name', + 'USER': 'username', + 'PASSWORD': 'password', + 'HOST': 'localhost', + 'PORT': '3306', + } + } +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'sbhs.sqlite3'), + } + } + +# Internationalization +# https://docs.djangoproject.com/en/1.6/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'Asia/Kolkata' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = False + +AUTH_USER_MODEL = 'tables.Account' +LOGIN_URL = '/sbhs/enter' +LOGOUT_URL = '/sbhs/logout' +SESSION_EXPIRE_AT_BROWSER_CLOSE = True +CSRF_COOKIE_NAME = "pfesgbxra" +SESSION_COOKIE_NAME = "frffvbaVq" + +EMAIL_HOST = 'smtp-auth.iitb.ac.in' +EMAIL_PORT = 25 +EMAIL_HOST_USER = "username" +EMAIL_HOST_PASSWORD = "password" + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.6/howto/static-files/ + + +if is_production: + BASE_URL = "http://vlabs.iitb.ac.in/sbhs/" + FORCE_SCRIPT_NAME = "/sbhs" + USE_X_FORWARDED_HOST = True +else: + BASE_URL = "http://127.0.0.1:8000/" + +SBHSCLIENT_STATIC_DIR = os.path.join(BASE_DIR, "client_static") +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, "static"), + os.path.join(SBHSCLIENT_STATIC_DIR, "zipped"), +) + +if is_production: + STATIC_ROOT = os.path.join(BASE_DIR, "production_static_files") + STATIC_URL = 'http://vlabs.iitb.ac.in/sbhs/static/' +else: + STATIC_URL = '/static/' + +TEMPLATE_DIRS = ( + os.path.join(BASE_DIR, 'templates/'), +) + + +import warnings +warnings.filterwarnings( + 'ignore', r"DateTimeField .* received a naive datetime", + RuntimeWarning, r'django\.db\.models\.fields') + +if not is_production: + import logging + l = logging.getLogger('django.db') + l.setLevel(logging.DEBUG) + l.addHandler(logging.StreamHandler()) + + LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + }, + }, + 'loggers': { + 'django.db': { + 'level': 'DEBUG', + 'handlers': ['console'], + }, + } + } +else: + LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': os.path.join(BASE_DIR, 'log/django_error.log'), + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['file'], + 'level': 'ERROR', + 'propagate': True, + } + } + } + +EXPERIMENT_LOGS_DIR = os.path.join(BASE_DIR, 'experiments') +WEBCAM_DIR = os.path.join(STATIC_ROOT, 'img/webcam/') if is_production else os.path.join(BASE_DIR, 'static/img/webcam/') +WEBCAM_STATIC_DIR = 'img/webcam/' + +if not is_production: + SBHS_ADMINS = ( + ("Amol Mandhane", "+91-9999999999", "amol_mandhane@iitb.ac.in"), + ("Amol Mandhane", "+91-9999999999", "amol_mandhane@iitb.ac.in"), + ) +else: + from sbhs_server.sbhs_admin_config import SBHS_ADMINS + +SBHS_GLOBAL_LOG_DIR = os.path.join(BASE_DIR, 'log') + +from sbhs_server import sbhs +boards = {} +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() + boards[str(key)] = {"board": brd, "experiment_id": None} + except: + pass + +online_mids = [int(i) for i in boards.keys()] + +import sys +print >>sys.stderr, online_mids[1:33] #srikant +#srikant +#f = open('/tmp/online_mids', 'w') +#f.write(online_mids) +#f.close() |