2013-09-23 16:37:40 +00:00
|
|
|
import logging
|
2013-10-01 03:54:12 +00:00
|
|
|
import os
|
2013-09-23 16:37:40 +00:00
|
|
|
|
2013-09-25 16:45:12 +00:00
|
|
|
from flask import Flask
|
2013-09-20 22:38:17 +00:00
|
|
|
from flask.ext.principal import Principal
|
2013-09-25 16:45:12 +00:00
|
|
|
from flask.ext.login import LoginManager
|
2013-09-27 23:29:01 +00:00
|
|
|
from flask.ext.mail import Mail
|
2013-10-03 20:19:01 +00:00
|
|
|
|
2014-04-03 22:47:17 +00:00
|
|
|
import features
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
from storage import Storage
|
|
|
|
from data.userfiles import Userfiles
|
2014-04-07 05:20:09 +00:00
|
|
|
from util.analytics import Analytics
|
2014-04-28 22:59:22 +00:00
|
|
|
from util.exceptionlog import Sentry
|
2014-04-10 19:20:16 +00:00
|
|
|
from data.billing import Billing
|
2014-05-09 22:45:11 +00:00
|
|
|
from data.buildlogs import BuildLogs
|
2013-10-03 20:19:01 +00:00
|
|
|
|
2013-09-20 15:55:44 +00:00
|
|
|
|
2014-04-07 20:59:22 +00:00
|
|
|
OVERRIDE_CONFIG_FILENAME = 'conf/stack/config.py'
|
|
|
|
|
|
|
|
|
2013-09-20 15:55:44 +00:00
|
|
|
app = Flask(__name__)
|
2013-10-03 20:19:01 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2013-10-01 03:54:12 +00:00
|
|
|
|
2014-04-07 20:59:22 +00:00
|
|
|
if 'TEST' in os.environ:
|
|
|
|
from test.testconfig import TestConfig
|
|
|
|
logger.debug('Loading test config.')
|
|
|
|
app.config.from_object(TestConfig())
|
|
|
|
else:
|
|
|
|
from config import DefaultConfig
|
|
|
|
logger.debug('Loading default config.')
|
|
|
|
app.config.from_object(DefaultConfig())
|
2014-04-03 21:31:46 +00:00
|
|
|
|
2014-04-07 20:59:22 +00:00
|
|
|
if os.path.exists(OVERRIDE_CONFIG_FILENAME):
|
|
|
|
logger.debug('Applying config file: %s', OVERRIDE_CONFIG_FILENAME)
|
|
|
|
app.config.from_pyfile(OVERRIDE_CONFIG_FILENAME)
|
2013-09-27 23:29:01 +00:00
|
|
|
|
2014-04-03 22:47:17 +00:00
|
|
|
features.import_features(app.config)
|
|
|
|
|
2014-03-17 16:01:13 +00:00
|
|
|
Principal(app, use_sessions=False)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
2014-04-09 03:05:45 +00:00
|
|
|
login_manager = LoginManager(app)
|
|
|
|
mail = Mail(app)
|
|
|
|
storage = Storage(app)
|
|
|
|
userfiles = Userfiles(app)
|
|
|
|
analytics = Analytics(app)
|
2014-04-10 19:20:16 +00:00
|
|
|
billing = Billing(app)
|
2014-04-28 22:59:22 +00:00
|
|
|
sentry = Sentry(app)
|
2014-05-09 22:45:11 +00:00
|
|
|
build_logs = BuildLogs(app)
|