+++ /dev/null
-"""
-Django settings for wsgiexample 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/
-"""
-
-# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
-import os
-import sys
-
-DJANGO_ROOT = os.path.dirname(__file__)
-PROJECT_ROOT = os.path.dirname(DJANGO_ROOT)
-
-# 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 = 'c=5&609$7)bm_u+3$2bi=ida$*a)c1(cp_0siua7uyww!1qfg_'
-
-DEFAULT_API_KEY = 'n7HsXGHIi0vp9j5u4TIRJyqAlXYc4wrH'
-
-# SECURITY WARNING: don't run with debug turned on in production!
-# Override in settings_local
-DEBUG = True
-
-TEMPLATE_DEBUG = True
-
-ALLOWED_HOSTS = ['jumpgate.caltech.edu']
-
-# Application definition
-AUTHENTICATION_BACKENDS = (
- 'samples.auth_backend.HTSUserModelBackend', )
-CUSTOM_USER_MODEL = 'samples.HTSUser'
-
-INSTALLED_APPS = (
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'django.contrib.humanize',
-
- 'eland_config',
- 'samples',
- 'experiments',
- 'bcmagic',
- 'inventory',
- 'labels',
-)
-
-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',
-)
-
-TEMPLATE_DIRS = (
- os.path.join(DJANGO_ROOT, 'templates'),
-)
-
-ROOT_URLCONF = 'htsworkflow.urls'
-
-WSGI_APPLICATION = 'wsgi.application'
-
-# Database
-# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
-
-DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(PROJECT_ROOT, 'fctracker.db'),
- }
-}
-
-EMAIL_HOST = 'localhost'
-
-# Internationalization
-# https://docs.djangoproject.com/en/1.6/topics/i18n/
-
-LANGUAGE_CODE = 'en-us'
-
-TIME_ZONE = 'UTC'
-
-USE_I18N = True
-
-USE_L10N = True
-
-USE_TZ = True
-
-TIME_ZONE='America/Los_Angeles'
-
-# Static files (CSS, JavaScript, Images)
-# https://docs.djangoproject.com/en/1.6/howto/static-files/
-STATICFILES_DIRS = (
- os.path.join(DJANGO_ROOT, 'static'),
-)
-STATIC_URL = '/static/'
-
-
-#####
-# Application specific settings
-DEFAULT_PM = 5
-
-# How often to recheck the result archive
-RESCAN_DELAY=1
-# Update this in settings_local to point to your flowcell result directory
-RESULT_HOME_DIR = os.path.join(PROJECT_ROOT, 'test', 'result', 'flowcells')
-
-# configure who is sending email and who should get BCCs of announcments
-NOTIFICATION_SENDER = "noreply@example.com"
-NOTIFICATION_BCC=[]
-
-try:
- # allow local customizations
- from settings_local import *
-except ImportError as e:
- pass
--- /dev/null
+"""
+Django settings for wsgiexample 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/
+"""
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+from os.path import abspath, basename, dirname, join, normpath
+import sys
+import logging
+
+from htsworkflow.util import config_helper
+
+DJANGO_ROOT = dirname(dirname(abspath(__file__)))
+PROJECT_ROOT = dirname(DJANGO_ROOT)
+
+INI_OPTIONS = config_helper.HTSWConfig()
+
+SECRET_KEY = INI_OPTIONS.setdefaultsecret('frontend', 'secret_key')
+DEFAULT_API_KEY = INI_OPTIONS.setdefaultsecret('frontend', 'api')
+
+# SECURITY WARNING: don't run with debug turned on in production!
+# Override in settings_local
+DEBUG = False
+
+TEMPLATE_DEBUG = False
+
+# Application definition
+AUTHENTICATION_BACKENDS = (
+ 'samples.auth_backend.HTSUserModelBackend', )
+CUSTOM_USER_MODEL = 'samples.HTSUser'
+
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'django.contrib.humanize',
+
+ 'eland_config',
+ 'samples',
+ 'experiments',
+ 'bcmagic',
+ 'inventory',
+ 'labels',
+]
+
+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',
+]
+
+TEMPLATE_DIRS = [
+ join(DJANGO_ROOT, 'templates'),
+]
+
+ROOT_URLCONF = 'htsworkflow.urls'
+
+WSGI_APPLICATION = 'wsgi.application'
+
+# Database
+# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
+
+EMAIL_HOST = 'localhost'
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.6/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE='America/Los_Angeles'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.6/howto/static-files/
+STATICFILES_DIRS = (
+ join(DJANGO_ROOT, 'static'),
+)
+STATIC_URL = '/static/'
+
+###
+# Application specific settings
+DEFAULT_PM = 5
+
+# How often to recheck the result archive
+RESCAN_DELAY=1
+
+# configure who is sending email and who should get BCCs of announcments
+NOTIFICATION_SENDER = "noreply@example.com"
+NOTIFICATION_BCC=[]
+
+# Update this in settings_local to point to your flowcell result directory
+RESULT_HOME_DIR = join(PROJECT_ROOT, 'test', 'result', 'flowcells')
--- /dev/null
+
+from .base import *
+
+LOGGING = {
+ 'version': 1,
+ 'disable_existing_loggers': False,
+ 'formatters': {
+ 'simple': {
+ 'format': '%(module)s %(levelname)s %(message)s',
+ }
+ },
+ 'handlers': {
+ 'console': {
+ 'class': 'logging.StreamHandler',
+ 'formatter': 'simple',
+ 'level': 'DEBUG',
+ 'stream': 'ext://sys.stdout'
+ }
+ },
+ 'loggers': {
+ 'htsworkflow': {
+ 'handlers': ['console'],
+ 'level': 'ERROR',
+ }
+ }
+}
--- /dev/null
+# configure debugging
+import os
+from .local import *
+
+DEBUG=True
+TEMPLATE_DEBUG = True
+
+INTERNAL_IPS = ('127.0.0.1',)
+
+MIDDLEWARE_CLASSES.extend([
+ #'debug_toolbar.middleware.DebugToolbarMiddleware',
+])
+
+DATABASES = {
+ #'default': {
+ #'ENGINE': 'django.db.backends.sqlite3',
+ #'NAME': os.path.join(settings.BASE_DIR, '..', 'fctracker.db'),
+ #}
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'HOST': 'felcat.caltech.edu',
+ 'USER': 'diane',
+ 'NAME': 'htsworkflow-django1.7',
+ }
+
+}
+
--- /dev/null
+from .base import *
+
+ALLOWED_HOSTS = ['jumpgate.caltech.edu']
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(PROJECT_ROOT, 'fctracker.db'),
+ }
+}
--- /dev/null
+"""Helper functions to manage ini file settings.
+"""
+import logging
+import os
+import ConfigParser
+
+from htsworkflow.util.api import make_django_secret_key
+
+LOGGER = logging.getLogger(__name__)
+
+class HTSWConfig(ConfigParser.SafeConfigParser):
+ '''Customization of SafeConfigParser that can open and save itself.
+ '''
+ def __init__(self, path=[os.path.expanduser("~/.htsworkflow.ini"),
+ '/etc/htsworkflow.ini',]):
+ # ConfigParser isn't a new-style class? lame
+ # super(ConfigParser.SafeConfigParser, self).__init__()
+ ConfigParser.SafeConfigParser.__init__(self)
+ read_path = self.read(path)
+ if len(read_path) > 0:
+ self.filename = read_path[0]
+ else:
+ self.filename = path[0]
+
+ def setdefaultsecret(self, section, key, length=216):
+ '''return current secret key, creating a new key if needed
+ '''
+ if not self.has_section(section):
+ self.add_section(section)
+
+ if not self.has_option(section, key):
+ secret = make_django_secret_key(length)
+ self.set(section, key, secret)
+ self.save()
+ return self.get(section, key)
+
+ def save(self):
+ try:
+ ini_stream = open(self.filename, 'w')
+ self.write(ini_stream)
+ ini_stream.close()
+ except IOError, e:
+ LOGGER.info("Error saving setting: %s" % (str(e)))
import sys
if __name__ == "__main__":
- os.environ.setdefault("DJANGO_SETTINGS_MODULE", "htsworkflow.settings")
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "htsworkflow.settings.local")
from django.core.management import execute_from_command_line