def setUp(self):
     config.load_config('./config.dev.json')
     config.MAILER_TYPE = 'QUEUE'
     config.DB_CONNECTION = 'sqlite:///{}'.format(self.SQLLITE_FILE)
     # When config.load_config is called, it sets self as the config in the
     # global store. Since we have mutated the config manually, we need to
     # re-set_config it in store.
     store.set_config(config)
     setup.init_db()
     # Clear mail queue
     mailer = mail.get_mailer()
     while len(mailer.queue):
         mailer.pop()
     self.app = app.make_app().test_client()
Exemple #2
0
 def setUp(self):
     config.load_config('./config.dev.json')
     config.MAILER_TYPE = 'QUEUE'
     config.DB_CONNECTION = 'sqlite:///{}'.format(self.SQLLITE_FILE)
     # When config.load_config is called, it sets self as the config in the
     # global store. Since we have mutated the config manually, we need to
     # re-set_config it in store.
     store.set_config(config)
     setup.init_db()
     # Clear mail queue
     mailer = mail.get_mailer()
     while len(mailer.queue):
         mailer.pop()
     self.app = app.make_app().test_client()
Exemple #3
0
#! /usr/bin/python3

import os
import logging
import argparse

from community_share import worker, config

logger = logging.getLogger(__name__)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    default_pid_dir = os.path.join('var', 'run', 'cs_worker')
    parser.add_argument('--pid-dir', dest='pid_dir', default=default_pid_dir)
    args = parser.parse_args()
    if args.pid_dir is not None:
        pid = str(os.getpid())
        with open(os.path.join(args.pid_dir, 'cs_worker.pid'), 'w') as f:
            f.write(pid)
    config.load_config('./config.production.json')
    logger.info('Starting community share worker.')
    worker.work_loop()
import logging
import sys

from community_share import config, app

logger = logging.getLogger(__name__)

logger.info('Loading settings from environment')
config.load_config('./config.dev.json')

if 'production' == config.APP_ENV:
    sys.exit('Cannot run development app with production config')

logger.info('Making application')
app = app.make_app()
app.debug = True
logger.info('Debug={0}'.format(app.debug))
app.run(host='0.0.0.0', port=5000, extra_files=['./manifest.json'])
Exemple #5
0
    from community_share.models.secret import Secret

    logger.info('Making Admin Users')
    make_admin_user('*****@*****.**', '*****@*****.**', 'admin')
    admin_emails = config.ADMIN_EMAIL_ADDRESSES.split(',')
    admin_emails = [x.strip() for x in admin_emails]
    logger.info('admin_emails is {0}'.format(admin_emails))
    for email in admin_emails:
        make_admin_user(email, email, Secret.make_key(20))

    logger.info('Making {0} random users'.format(n_random_users))
    password_hash = User.pwd_context.encrypt('password')
    for i in range(n_random_users):
        make_random_user(password_hash=password_hash)
    creator = get_creator()
    logger.info('Creator of questions is {}'.format(creator.email))
    questions = setup_data.get_questions(creator)
    update_questions(questions)
    store.session.commit()
    creator = get_creator()
    questions = setup_data.get_questions(creator)
    update_questions(questions)
    store.session.commit()


if __name__ == '__main__':
    logger.info('Loading settings from environment')
    config.load_config('./config.dev.json')
    logger.info('Finished loading settings')
    setup(n_random_users=40)