Beispiel #1
0
def init_mail(app=None):
    """
    flask-mail i initialize eder
    """
    if app is None:
        app = current_app

    mail = Mail()

    try:
        universite_id = SessionHandler.universite_id()
        ayarlar = DB.session.query(SiteAyarlari).filter_by(
            universite_id=universite_id).first()
        mail_sunucu_ayarlari = ayarlar.params["mail_sunucu_ayarlari"]
        mail_config = {
            "MAIL_SERVER": mail_sunucu_ayarlari['mail_server'],
            "MAIL_PORT": mail_sunucu_ayarlari['mail_port'],
            "MAIL_USE_TLS": mail_sunucu_ayarlari['mail_use_tls'],
            "MAIL_USE_SSL": mail_sunucu_ayarlari['mail_use_ssl'],
            "MAIL_USERNAME": mail_sunucu_ayarlari['mail_username'],
            "MAIL_PASSWORD": ayarlar.mail_password,
            "MAIL_DEFAULT_SENDER": mail_sunucu_ayarlari['mail_default_sender'],
            "MAIL_MAX_EMAILS": mail_sunucu_ayarlari['mail_max_emails']
        }
        app.logger.info("Mail ayarlari databaseden tekrar yuklendi")
        state = mail.init_mail(config=mail_config)
        app.extensions['mail'] = state

    except (AttributeError, RuntimeError, InternalError, ProgrammingError):
        app.logger.info(
            "Mail ayarlari databaseden yuklenemedi config'den aliniyor")
        mail.init_app(app=app)
Beispiel #2
0
    handler = logging.StreamHandler()
    formatter = logging.Formatter('[%(asctime)s][PID:%(process)d][%(levelname)s][%(name)s] %(message)s')
    handler.setFormatter(formatter)
    logging.getLogger().addHandler(handler)
    logging.getLogger().setLevel(settings.LOG_LEVEL)
    logging.getLogger("passlib").setLevel("ERROR")


def create_redis_connection():
    redis_url = urlparse.urlparse(settings.REDIS_URL)
    if redis_url.path:
        redis_db = redis_url.path[1]
    else:
        redis_db = 0

    r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_url.password)

    return r


setup_logging()
redis_connection = create_redis_connection()
mail = Mail()
mail.init_mail(settings.all_settings())
statsd_client = StatsClient(host=settings.STATSD_HOST, port=settings.STATSD_PORT, prefix=settings.STATSD_PREFIX)

import_query_runners(settings.QUERY_RUNNERS)

from redash.version_check import reset_new_version_status
reset_new_version_status()
Beispiel #3
0
        else:
            redis_db = 0

        r = redis.StrictRedis(host=redis_url.hostname,
                              port=redis_url.port,
                              db=redis_db,
                              password=redis_url.password)

    return r


setup_logging()
redis_connection = create_redis_connection()
mail = Mail()
migrate = Migrate()
mail.init_mail(settings.all_settings())
statsd_client = StatsClient(host=settings.STATSD_HOST,
                            port=settings.STATSD_PORT,
                            prefix=settings.STATSD_PREFIX)
limiter = Limiter(key_func=get_ipaddr, storage_uri=settings.REDIS_URL)

import_query_runners(settings.QUERY_RUNNERS)
import_destinations(settings.DESTINATIONS)

from redash.version_check import reset_new_version_status
reset_new_version_status()


class SlugConverter(BaseConverter):
    def to_python(self, value):
        # This is an ugly workaround for when we enable multi-org and some files are being called by the index rule:
Beispiel #4
0
from views.job import job_info,add_job_tag,search_job,search_more_requirement,\
    get_work_message,search_tag,search_addr,get_count
from views.comment import get_comment,post_comment

from models.user import User

app = Flask(__name__)
app.secret_key = Config.SUCCESS_KEY
app.permanent_session_lifetime = timedelta(minutes=60)
app.config["SQLALCHEMY_DATABASE_URI"] = Config.db

app.sa_engine = create_engine(Config.db)
app.DBSession = scoped_session(sessionmaker(bind=app.sa_engine))

mail = Mail(app)
mail.init_mail(Config.email)

# ---index---

app.add_url_rule("/index/<int:page>" ,methods=["GET"],
                 view_func=index_job_info)
app.add_url_rule("/", methods=["GET"],
                 view_func=index_info)


# ----user----

app.add_url_rule("/register", methods=["GET", "POST"],
                 view_func=user_register)
app.add_url_rule("/login", methods=["GET", "POST"],
                 view_func=user_login)