2013-09-23 16:37:40 +00:00
|
|
|
import logging
|
2013-10-01 03:54:12 +00:00
|
|
|
import os
|
2013-10-02 04:48:03 +00:00
|
|
|
import stripe
|
2014-04-03 21:31:46 +00:00
|
|
|
import json
|
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 config import DefaultConfig
|
|
|
|
from data.userfiles import Userfiles
|
2014-04-07 05:20:09 +00:00
|
|
|
from util.analytics import Analytics
|
2013-10-03 20:19:01 +00:00
|
|
|
|
2013-09-20 15:55:44 +00:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
2013-10-03 20:19:01 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
logger.debug('Loading default config.')
|
|
|
|
app.config.from_object(DefaultConfig())
|
2013-10-01 03:54:12 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
if 'QUAY_CONFIG_FILE' in os.environ:
|
|
|
|
config_filename = os.environ['QUAY_CONFIG_FILE']
|
|
|
|
logger.debug('Applying config file: %s', config_filename)
|
|
|
|
app.config.from_pyfile(config_filename)
|
|
|
|
|
|
|
|
overrides = json.loads(os.environ.get('QUAY_CONFIG', '{}'))
|
|
|
|
logger.debug('Applying %s config overrides.', len(overrides))
|
|
|
|
app.config.from_object(overrides)
|
2013-09-27 23:29:01 +00:00
|
|
|
|
2014-04-03 22:47:17 +00:00
|
|
|
features.import_features(app.config)
|
|
|
|
|
|
|
|
print "Billing: %s" % features.BILLING
|
|
|
|
|
2014-03-17 16:01:13 +00:00
|
|
|
Principal(app, use_sessions=False)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
2013-09-23 16:37:40 +00:00
|
|
|
login_manager = LoginManager()
|
|
|
|
login_manager.init_app(app)
|
2013-09-27 23:29:01 +00:00
|
|
|
|
|
|
|
mail = Mail()
|
|
|
|
mail.init_app(app)
|
2013-10-02 04:48:03 +00:00
|
|
|
|
2014-04-03 21:31:46 +00:00
|
|
|
storage = Storage()
|
|
|
|
storage.init_app(app)
|
|
|
|
|
|
|
|
userfiles = Userfiles()
|
|
|
|
userfiles.init_app(app)
|
|
|
|
|
2013-11-07 04:21:12 +00:00
|
|
|
stripe.api_key = app.config.get('STRIPE_SECRET_KEY', None)
|
2013-10-03 20:19:01 +00:00
|
|
|
|
2014-04-07 05:20:09 +00:00
|
|
|
analytics = Analytics()
|
|
|
|
analytics.init_app(app)
|