django-nose didn't work with django 1.1, so I went back to the nose plugin NoseDjango
[htsworkflow.git] / settings.py
1 """
2 Generate settings for the Django Application.
3
4 To make it easier to customize the application the settings can be 
5 defined in a configuration file read by ConfigParser.
6
7 The options understood by this module are (with their defaults):
8
9   [frontend]
10   email_host=localhost
11   email_port=25
12   database_engine=sqlite3
13   database_name=/path/to/db
14
15   [admins]
16   #name1=email1
17
18   [allowed_hosts]
19   #name1=ip
20   localhost=127.0.0.1
21   
22   [allowed_analysis_hosts]
23   #name1=ip
24   localhost=127.0.0.1
25
26 """
27 import ConfigParser
28 import os
29 import shlex
30
31 # make epydoc happy
32 __docformat__ = "restructuredtext en"
33
34 def options_to_list(options, dest, section_name, option_name):
35   """
36   Load a options from section_name and store in a dictionary
37   """
38   if options.has_option(section_name, option_name):
39     opt = options.get(section_name, option_name)
40     dest.extend( shlex.split(opt) )
41       
42 def options_to_dict(dest, section_name):
43   """
44   Load a options from section_name and store in a dictionary
45   """
46   if options.has_section(section_name):
47     for name in options.options(section_name):
48       dest[name] = options.get(section_name, name)
49
50 # define your defaults here
51 options = ConfigParser.SafeConfigParser(
52            { 'email_host': 'localhost',
53              'email_port': '25', 
54              'database_engine': 'sqlite3',
55              'database_name': 
56                os.path.abspath('../../fctracker.db'),
57              'time_zone': 'America/Los_Angeles',
58              'default_pm': '5',
59              'link_flowcell_storage_device_url': "http://localhost:8000/inventory/lts/link/",
60              'printer1_host': '127.0.0.1',
61              'printer1_port': '9100',
62              'printer2_host': '127.0.0.1',
63              'printer2_port': '9100',
64            })
65
66 options.read([os.path.expanduser("~/.htsworkflow.ini"),
67               '/etc/htsworkflow.ini',])
68
69 # OptionParser will use the dictionary passed into the config parser as
70 # 'Default' values in any section. However it still needs an empty section
71 # to exist in order to retrieve anything.
72 if not options.has_section('frontend'):
73     options.add_section('frontend')
74 if not options.has_section('bcprinter'):
75     options.add_section('bcprinter')
76
77
78 # Django settings for elandifier project.
79
80 DEBUG = True
81 TEMPLATE_DEBUG = DEBUG
82
83 ADMINS = []
84 options_to_list(options, ADMINS, 'frontend', 'admins')
85
86 MANAGERS = []
87 options_to_list(options, MANAGERS, 'frontend', 'managers')
88
89 AUTHENTICATION_BACKENDS = ( 
90   'htsworkflow.frontend.samples.auth_backend.HTSUserModelBackend', )
91 CUSTOM_USER_MODEL = 'samples.HTSUser' 
92
93 EMAIL_HOST = options.get('frontend', 'email_host')
94 EMAIL_PORT = int(options.get('frontend', 'email_port'))
95
96 if options.has_option('frontend', 'notification_sender'):
97     NOTIFICATION_SENDER = options.get('frontend', 'notification_sender')
98 else:
99     NOTIFICATION_SENDER = "noreply@example.com"
100 NOTIFICATION_BCC = []
101 options_to_list(options, NOTIFICATION_BCC, 'frontend', 'notification_bcc')
102
103 # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
104 DATABASE_ENGINE = options.get('frontend', 'database_engine')
105
106 # Or path to database file if using sqlite3.
107 DATABASE_NAME = options.get('frontend', 'database_name' )
108 DATABASE_USER = ''             # Not used with sqlite3.
109 DATABASE_PASSWORD = ''         # Not used with sqlite3.
110 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
111 DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
112
113 # Local time zone for this installation. Choices can be found here:
114 # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
115 # although not all variations may be possible on all operating systems.
116 # If running in a Windows environment this must be set to the same as your
117 # system time zone.
118 TIME_ZONE = options.get('frontend', 'time_zone')
119
120 # Language code for this installation. All choices can be found here:
121 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
122 # http://blogs.law.harvard.edu/tech/stories/storyReader$15
123 LANGUAGE_CODE = 'en-us'
124
125 SITE_ID = 1
126
127 # If you set this to False, Django will make some optimizations so as not
128 # to load the internationalization machinery.
129 USE_I18N = True
130
131 # Absolute path to the directory that holds media.
132 # Example: "/home/media/media.lawrence.com/"
133 MEDIA_ROOT = os.path.abspath(os.path.split(__file__)[0]) + '/static/'
134
135 # URL that handles the media served from MEDIA_ROOT.
136 # Example: "http://media.lawrence.com"
137 MEDIA_URL = '/static/'
138
139 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
140 # trailing slash.
141 # Examples: "http://foo.com/media/", "/media/".
142 ADMIN_MEDIA_PREFIX = '/media/'
143
144 # Make this unique, and don't share it with anybody.
145 SECRET_KEY = '(ekv^=gf(j9f(x25@a7r+8)hqlz%&_1!tw^75l%^041#vi=@4n'
146
147 # some of our urls need an api key
148 DEFAULT_API_KEY = 'n7HsXGHIi0vp9j5u4TIRJyqAlXYc4wrH'
149
150 # List of callables that know how to import templates from various sources.
151 TEMPLATE_LOADERS = (
152     'django.template.loaders.filesystem.load_template_source',
153     'django.template.loaders.app_directories.load_template_source',
154 #     'django.template.loaders.eggs.load_template_source',
155 )
156
157 MIDDLEWARE_CLASSES = (
158     'django.middleware.common.CommonMiddleware',
159     'django.contrib.sessions.middleware.SessionMiddleware',
160     'django.contrib.auth.middleware.AuthenticationMiddleware',
161     'django.middleware.doc.XViewMiddleware',
162 )
163
164 ROOT_URLCONF = 'htsworkflow.frontend.urls'
165
166 TEMPLATE_DIRS = (
167     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
168     # Always use forward slashes, even on Windows.
169     # Don't forget to use absolute paths, not relative paths.
170     '/usr/share/python-support/python-django/django/contrib/admin/templates',
171     #'/usr/lib/pymodules/python2.6/django/contrib/admin/templates/',
172     os.path.join(os.path.split(__file__)[0],
173                  'htsworkflow', 'frontend','templates'),
174 )
175
176 INSTALLED_APPS = (
177     'django.contrib.admin',
178     'django.contrib.auth',
179     'django.contrib.contenttypes',
180     'django.contrib.humanize',
181     'django.contrib.sessions',
182     'django.contrib.sites',
183     'htsworkflow.frontend.eland_config',
184     'htsworkflow.frontend.samples',
185     # modules from htsworkflow branch
186     'htsworkflow.frontend.experiments',
187     'htsworkflow.frontend.analysis', 
188     'htsworkflow.frontend.reports',
189     'htsworkflow.frontend.inventory',
190     'htsworkflow.frontend.bcmagic',
191     'django.contrib.databrowse',
192 )
193
194 # Project specific settings
195
196 ALLOWED_IPS={'127.0.0.1': '127.0.0.1'}
197 options_to_dict(ALLOWED_IPS, 'allowed_hosts')
198
199 ALLOWED_ANALYS_IPS = {'127.0.0.1': '127.0.0.1'}
200 options_to_dict(ALLOWED_ANALYS_IPS, 'allowed_analysis_hosts')
201 #UPLOADTO_HOME = os.path.abspath('../../uploads')
202 #UPLOADTO_CONFIG_FILE = os.path.join(UPLOADTO_HOME, 'eland_config')
203 #UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')
204 #UPLOADTO_BED_PACKS = os.path.join(UPLOADTO_HOME, 'bed_packs')
205 # Where "results_dir" means directory with all the flowcells
206 if options.has_option('frontend', 'results_dir'):
207     RESULT_HOME_DIR=os.path.expanduser(options.get('frontend', 'results_dir'))
208 else:
209     RESULT_HOME_DIR='/tmp'
210
211 LINK_FLOWCELL_STORAGE_DEVICE_URL = options.get('frontend', 'link_flowcell_storage_device_url')
212 # PORT 9100 is default for Zebra tabletop/desktop printers
213 # PORT 6101 is default for Zebra mobile printers
214 BCPRINTER_PRINTER1_HOST = options.get('bcprinter', 'printer1_host')
215 BCPRINTER_PRINTER1_PORT = int(options.get('bcprinter', 'printer1_port'))
216 BCPRINTER_PRINTER2_HOST = options.get('bcprinter', 'printer2_host')
217 BCPRINTER_PRINTER2_PORT = int(options.get('bcprinter', 'printer2_port'))
218
219 DEFAULT_PM=int(options.get('frontend', 'default_pm'))