This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
forked from felipelerena/FlightDeck
-
Notifications
You must be signed in to change notification settings - Fork 20
/
settings.py
408 lines (332 loc) · 11.1 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
"""
Default settings for the FlightDeck site
For local configuration please use settings_local.py
"""
import os
import logging
import socket
import tempfile
# Make filepaths relative to settings.
ROOT = os.path.dirname(os.path.abspath(__file__))
path = lambda *a: os.path.join(ROOT, *a)
# Set the project version
PROJECT_VERSION = "1.0.11"
# TODO: This should be handled by prod in a settings_local. By default, we
# shouldn't be in prod mode
# If PRODUCTION do not load development apps
PRODUCTION = True
# Django settings for flightdeck project.
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('clouserw', '[email protected]'),
('zalun', '[email protected]'),
('dbuc', '[email protected]'),
('seanmonstar', '[email protected]'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'NAME': 'zamboni',
'ENGINE': 'django.db.backends.mysql',
'HOST': '',
'PORT': '',
'USER': '',
'PASSWORD': '',
'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'},
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_general_ci',
},
}
# Logging (copied from zamboni)
LOG_LEVEL = logging.DEBUG
HAS_SYSLOG = True # syslog is used if HAS_SYSLOG and NOT DEBUG.
SYSLOG_TAG = "http_app_builder"
# See PEP 391 and log_settings.py for formatting help. Each section of LOGGING
# will get merged into the corresponding section of log_settings.py.
# Handlers and log levels are set up automatically based on LOG_LEVEL and DEBUG
# unless you set them here. Messages will not propagate through a logger
# unless propagate: True is set.
LOGGING_CONFIG = None
LOGGING = {
'loggers': {
'amqplib': {'handlers': ['null']},
'celery': {'level': logging.ERROR},
'nose.plugins.manager': {'level': logging.INFO},
'pyes': {'handlers': ['null']},
'rdflib': {'handlers': ['null']},
},
}
# How many packages per type should be displayed on the homepage
HOMEPAGE_ITEMS_LIMIT = 5
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE = 'America/Los_Angeles'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# The host currently running the site. Only use this in code for good reason;
# the site is designed to run on a cluster and should continue to support that
HOSTNAME = socket.gethostname()
# Paths settings
MEDIA_ROOT = path('media')
FRAMEWORK_PATH = path()
SDK_SOURCE_DIR = path('lib') # TODO: remove this var
APP_MEDIA_PREFIX = os.path.join(FRAMEWORK_PATH, 'apps')
UPLOAD_DIR = path('upload')
VIRTUAL_ENV = os.environ.get('VIRTUAL_ENV') # TODO: remove this var
# jetpack defaults
PACKAGES_PER_PAGE = 10
MINIMUM_PACKAGE_ID = 1000000
INITIAL_VERSION_NAME = 'initial'
PACKAGE_PLURAL_NAMES = {
'l': 'libraries',
'a': 'addons'
}
PACKAGE_SINGULAR_NAMES = {
'l': 'library',
'a': 'addon'
}
DEFAULT_PACKAGE_SUFFIX = {
'l': '-lib'
}
HOMEPAGE_PACKAGES_NUMBER = 3
SDKDIR_PREFIX = tempfile.gettempdir() # removed after xpi is created
XPI_TARGETDIR = tempfile.gettempdir() # target dir - in shared directory
XULRUNNER_BINARY = '/usr/bin/xulrunner'
LIBRARY_AUTOCOMPLETE_LIMIT = 20
KEYDIR = 'keydir'
JETPACK_NEW_IS_BASE = False
JETPACK_ITEMS_PER_PAGE = 10
JETPACK_LIB_DIR = 'lib'
JETPACK_DATA_DIR = 'data'
ATTACHMENT_MAX_FILESIZE = 2 * 1024 * 1024 # 2MB
PYTHON_EXEC = 'python'
# amo defaults
XPI_AMO_PREFIX = "ftp://ftp.mozilla.org/pub/mozilla.org/addons/"
# The lowest approved SDK available for add-ons
DISABLED_SDKS = ('1.4', '1.4.1', '1.4.1-w-1', '1.4.2', '1.13', '1.13.1', '1.14rc1')
LOWEST_APPROVED_SDK = "1.14"
TEST_SDK = 'addon-sdk-1.14'
TEST_AMO_USERNAME = None
TEST_AMO_PASSWORD = None
AUTH_DATABASE = None
AMO_SECRET_KEY = "notsecure"
# add directory to desired SDK else latest imported SDK will be used
REPACKAGE_SDK_SOURCE = None
BUILDER_SECRET_KEY = 'notsecure'
DOMAIN = "builder.addons.mozilla.org"
SITE_URL = "https://%s" % DOMAIN
# AMO OAUTH DATA
AMOOAUTH_DOMAIN = "addons.mozilla.org"
AMOOAUTH_PORT = 443
AMOOAUTH_PROTOCOL = "https"
AMOOAUTH_CONSUMERKEY = "key"
AMOOAUTH_CONSUMERSECRET = "secret"
AMOOAUTH_PREFIX = "/z"
UPLOADTOAMO = True
# AMO GENERIC API
AMOAPI_VERSION = "1.5"
AMOAPI_PROTOCOL = "https"
AMOAPI_DOMAIN = "services.addons.mozilla.org"
AMOAPI_PORT = 443
AMO_SITE_PROTOCOL = 'https'
AMO_SITE_DOMAIN = 'addons.mozilla.org'
URLOPEN_TIMEOUT = 4 # default timeout for urllib2.urlopen (seconds)
# set it in settings_local.py if AMO auth should be used
#AUTH_DATABASE = {
# 'NAME': 'db_name',
# 'TABLE': 'users_table_name',
# 'USER': 'db_user',
# 'PASSWORD': '', # db_password
# 'HOST': '',
# 'PORT': ''
#}
# Media section
APP_MEDIA_SUFFIX = 'media'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# Settings for user management
LOGIN_URL = '/user/signin/'
LOGIN_REDIRECT_URL = '/user/dashboard/'
AUTH_PROFILE_MODULE = 'person.Profile'
AUTHENTICATION_BACKENDS = (
'amo.authentication.AMOAuthentication',
)
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/adminmedia/'
# Title to be displayed on the Admin site
ADMIN_TITLE = "Add-on Builder Administration"
SITE_ID = 1
# Title to be used on the page
SITE_TITLE = "Add-on Builder"
# Define in settings_local.py ake this unique, and don't share it with anybody.
SECRET_KEY = 'somesecretkey'
# Cookies which should not have the httponly set to true
JAVASCRIPT_READABLE_COOKIES = ()
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_NAME = "bamo_sessionid"
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'jingo.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
JINGO_EXCLUDE_APPS = [
'debug_toolbar'
]
JINJA_CONFIG = {'autoescape': False}
def JINJA_CONFIG():
import jinja2
from django.conf import settings
config = {'extensions': ['jinja2.ext.do',
'jinja2.ext.with_', 'jinja2.ext.loopcontrols'],
'finalize': lambda x: x if x is not None else ''}
return config
MIDDLEWARE_CLASSES = [
# Munging REMOTE_ADDR must come before ThreadRequest.
'commonware.response.middleware.GraphiteRequestTimingMiddleware',
'commonware.response.middleware.GraphiteMiddleware',
'commonware.middleware.SetRemoteAddrFromForwardedFor',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'utils.cookies.HttpOnlyMiddleware',
'waffle.middleware.WaffleMiddleware',
'commonware.middleware.FrameOptionsHeader',
'commonware.middleware.ScrubRequestOnException',
'utils.middleware.GetUserInfoOnException',
]
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
'base.context_processors.settings',
'base.context_processors.uri',
'django.contrib.messages.context_processors.messages',
'person.context_processors.profile',
'django.core.context_processors.request',
)
ROOT_URLCONF = 'urls'
ADDONS_HELPER_URL = ('https://addons.mozilla.org/firefox/downloads/latest/'
'182410?src=external-builder')
# desired ABH version
# Builder will display a warning if the version is lower than this number
ADDONS_HELPER_VERSION = '1.4'
TEMPLATE_DIRS = ()
# Change default test runner (works only with mysql)
TEST_RUNNER = 'test_utils.runner.RadicalTestSuiteRunner'
# Modify in settings_local if needed
SELENIUM_CONFIG = {}
# Django toolbar configuration
DEBUG_TOOLBAR_CONFIG = {
# change to True needed if debugging creation of Add-ons
'INTERCEPT_REDIRECTS': False
}
# Switch on debug_toolbar for these IPs
INTERNAL_IPS = ('127.0.0.1',)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.markup',
'django.contrib.messages',
'django_browserid',
# database migrations not implemented yet
# 'south',
# DEV_APPS
'django_extensions',
'debug_toolbar',
'django_nose',
# FLIGHTDECK APPS
'base', # basic flightdeck things (utils, urls)
'person', # user related stuff (profile etc.)
'search', # ElasticSearch and search views.
'amo', # currently addons.mozilla.org authentication
'jetpack', # Jetpack functionality
'xpi', # XPI management
'repackage', # repackaging XPI
'tutorial', # Load tutorial templates
'cronjobs',
# 3RD PARTY APPS
'djcelery',
'raven.contrib.django',
'waffle',
]
# Which from above apps should be removed if in PRODUCTION
DEV_APPS = (
'django_extensions',
'debug_toolbar',
'django_nose',
)
# Which from above Middleware classes should be removed if in PRODUCTION
DEV_MIDDLEWARE_CLASSES = (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
# If you want to run Selenium tests, you'll need to have a server running.
# Then give this a dictionary of settings. Something like:
#SELENIUM_CONFIG = {
# 'HOST': 'localhost',
# 'PORT': 4444,
# 'BROWSER': '*firefox',
#}
import djcelery
djcelery.setup_loader()
# These settings are for if you have celeryd running
# BROKER_HOST = 'localhost'
# BROKER_PORT = 5672
# BROKER_USER = 'builder'
# BROKER_PASSWORD = 'builder'
# BROKER_VHOST = 'builder'
# BROKER_CONNECTION_TIMEOUT = 0.1
# CELERY_RESULT_BACKEND = 'amqp'
# CELERY_IGNORE_RESULT = True
# Setting this to true will bypass celeryd and execute tasks in-process
CELERY_ALWAYS_EAGER = True
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
CELERY_ROUTES = {
'repackage.tasks.low_rebuild': {'queue': 'builder_bulk'},
}
ENGAGE_ROBOTS = False
# For search:
# Checkout flightdeck-es and run bin/elasticsearch -f
ES_DISABLED = True
ES_INDEXES = {
'default': 'flightdeck',
}
ES_TIMEOUT = 5 #timeout duration
ES_RETRY = 2 #times to retry on timeout
ES_RETRY_INTERVAL = 0.25 #wait between attempts
# Graphite reporting
STATSD_HOST = "localhost"
STATSD_PORT = 8125
STATSD_PREFIX = "builder"
GRAPHITE_HOST = STATSD_HOST
GRAPHITE_PORT = 2003
GRAPHITE_PREFIX = STATSD_PREFIX
GRAPHITE_TIMEOUT = 1
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
'TIMEOUT': 60,
'KEY_PREFIX': 'bamo',
}
}
try:
from build import BUILD_ID
except ImportError:
BUILD_ID = 'dev'
ATTACHMENT_PROTOCOL = 'https'
ATTACHMENT_PORT = 443
ATTACHMENT_DOMAIN = None