Example #1
0
import envoy
import heroku
import requests

from flask import Flask, request, Response
from flask.ext.celery import Celery
from raven.contrib.flask import Sentry

import urllib


app = Flask(__name__)

redis_url = os.environ.get("REDISTOGO_URL", "redis://localhost:6379/0")

app.config["BROKER_URL"] = redis_url
app.config["CELERY_ENABLE_UTC"] = True
app.config["CELERYD_POOL"] = "gevent"

celery = Celery(app)
# sentry = Sentry(app)

HEROKU_EMAIL = os.environ.get("HEROKU_EMAIL")
HEROKU_PASS = os.environ.get("HEROKU_PASS")

heroku = heroku.from_pass(HEROKU_EMAIL, HEROKU_PASS)


@celery.task(name="yoshi.install")
def install(package, connect=False):
Example #2
0
console_format = logging.Formatter(" %(asctime)s %(levelname)s: %(message)s [in %(module)s:%(lineno)d]")
console_logger.setFormatter(console_format)
console_logger.setLevel(logging.WARNING)
app.logger.addHandler(console_logger)


if os.environ.get("EXTERNAL"):
    app.config["MONGO_URI"] = os.environ["MONGO_URI"]
    app.config["MONGO_CONNECT"] = False
    app.secret_key = os.environ["random_key"]
    app.config["BROKER_URL"] = os.environ["REDIS_URL"]  # Celery
    app.config["CELERY_RESULT_BACKEND"] = os.environ["REDIS_URL"]
else:
    with open("../Other-Secrets/TITDev.json") as secrets_file:
        secrets = json.load(secrets_file)
    app.config["MONGO_HOST"] = secrets["mongo-host"]
    app.config["MONGO_DBNAME"] = secrets["mongo-db"]
    app.config["MONGO_USERNAME"] = secrets["mongo-user"]
    app.config["MONGO_PASSWORD"] = secrets["mongo-password"]
    app.config["MONGO_PORT"] = secrets["mongo-port"]
    app.config["BROKER_URL"] = secrets["redis-host"]  # Celery
    app.config["CELERY_RESULT_BACKEND"] = secrets["redis-host"]
    app.config["MONGO_CONNECT"] = False
    app.secret_key = secrets["random_key"]

Bootstrap(app)
cdn_theme_url = "https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/slate/"
app.extensions["bootstrap"]["cdns"]["theme"] = WebCDN(cdn_theme_url)  # CDN Theme
app_mongo = PyMongo(app)

# Redis