Beispiel #1
0
def flaskr_client(context, *args, **kwargs):
    APP.config['DATABASE'] = {'engine': 'peewee.SqliteDatabase', 'name': ':memory:'}
    # context.db, APP.config['DATABASE'] = tempfile.mkstemp()
    APP.testing = True
    context.client = APP.test_client()

    with APP.app_context():
        DB = Database(APP)
        init_models(DB)
        # pass
    yield context.client
Beispiel #2
0
def flaskr_client(context, *args, **kwargs):
    context.db, APP.config['DATABASE'] = tempfile.mkstemp()
    APP.testing = True
    context.client = APP.test_client()

    with APP.app_context():
        # init_db()
        pass
    yield context.client

    # -- CLEANUP:
    os.close(context.db)
    os.unlink(APP.config['DATABASE'])
Beispiel #3
0
def make_test_app_instance(context, *args, **kwargs):

    APP(test_settings, force_init_web_app=True)
    context.client = APP.web_app.test_client()
    APP.web_app.testing = True
    APP.init_extensions()  # Иницализируем расширения

    with APP.db.database.connection_context(
    ):  # Пересозадём таблицы для тестов
        APP.extensions['db'].drop_tables()
        APP.extensions['db'].create_tables()

    yield context.client
    def setUp(self):
        APP.config['TESTING'] = True
        APP.config['WTF_CSRF_ENABLED'] = False
        APP.config['DEBUG'] = False

        # Check for environment variable
        if not os.getenv("DATABASE_URL"):
            raise RuntimeError("DATABASE_URL is not set")
        # Base.query = db_session.query_property()
        self.APP = APP.test_client()
        self.assertEqual(APP.debug, False)
Beispiel #5
0
from log import add_loggers


if __name__ == '__main__':

    from application import APP
    log = APP.web_app.logger
    add_loggers(APP)

    if not os.path.isfile('local_settings.py.tmpl'):
        err_txt = 'Отсутствует шаблон локального файла настроек.'
        log.error(err_txt)
        raise FileNotFoundError(err_txt)
    else:

        try:
            import local_settings
        except ImportError:
            copyfile('local_settings.py.tmpl', 'local_settings.py')
            log.warning('Отсутствует локальный файл настроек. Файл создан из шаблона local_settings.py.tmpl')

        try:
            log.info('Launched: application %s' % datetime.now())

            APP(local_settings)
            APP.init_extensions()  # Иницализируем расширения
            APP.web_app.run()  # Запускаем приложение

        except Exception as e:
            log.error(e)
Beispiel #6
0
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)
    return logger


if __name__ == '__main__':

    log = make_loggers()

    if not os.path.isfile('local_settings.py.tmpl'):
        log.error('Отсутствует шаблон локального файла настроек.')

    else:

        try:
            import local_settings
        except ImportError:
            copyfile('local_settings.py.tmpl', 'local_settings.py')
            log.warning(
                'Отсутствует локальный файл настроек. Файл создан из шаблона local_settings.py.tmpl'
            )

        try:
            log.debug('Launched: application %s' % datetime.now())
            from application import APP
            APP.run(host='0.0.0.0', port=5001)
        except Exception as e:
            log.exception(e)
Beispiel #7
0
#!/usr/bin/env python

from application import APP


if __name__ == '__main__':
    APP.debug = True
    APP.run(port=9000)
Beispiel #8
0
# coding:utf-8
'''
Entry for the application.
'''

import sys
from config import SITE_CFG
import tornado.ioloop

PORT = SITE_CFG['PORT']

from application import APP

if __name__ == "__main__":
    # tornado.locale.set_default_locale('zh_CN')
    # tornado.locale.load_gettext_translations('locale', 'yunsuan')
    if len(sys.argv) > 1:
        PORT = sys.argv[1]

    APP.listen(PORT)
    print(
        'Development server is running at http://127.0.0.1:{0}/'.format(PORT))
    print('Quit the server with CONTROL-C')
    tornado.ioloop.IOLoop.instance().start()
Beispiel #9
0
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)
    return logger


if __name__ == '__main__':

    log = make_loggers()

    if not os.path.isfile('local_settings.py.tmpl'):
        log.error('Отсутствует шаблон локального файла настроек.')

    else:

        try:
            import local_settings
        except ImportError:
            copyfile('local_settings.py.tmpl', 'local_settings.py')
            log.warning(
                'Отсутствует локальный файл настроек. Файл создан из шаблона local_settings.py.tmpl'
            )

        try:
            log.debug('Launched: application %s' % datetime.now())
            from application import APP
            APP.run()
        except Exception as e:
            log.exception(e)
Beispiel #10
0
#!flask/bin/python
from application import APP
from application import GAME
APP.run(debug=True, threaded=True)
Beispiel #11
0
# -*- coding:utf-8 -*-
import tornado.httpserver
import tornado.web
import tornado.ioloop
import tornado.escape
from tornado.options import define, options
from application import APP

define("port", default=8000, help="run port ", type=int)
define("t", default=False, help="creat tables", type=bool)

if __name__ == "__main__":
    options.parse_command_line()
    if options.t:
        # create_talbes.run()
        print("create tables")

    APP.listen(options.port)
    # print 'start server'
    tornado.ioloop.IOLoop.instance().start()