def create_app(config_filename=None): app = Flask(__name__, instance_relative_config=True) if app.config.from_pyfile("settings.conf", silent=True): print "Settings loaded from local instance" if app.config.from_envvar("RSVP_CONF", silent=True): print "Settings loaded from ENVVAR" if app.config["DEBUG"]: app.debug = True log_formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") root_logger = logging.getLogger("werkzeug") if app.config["DEBUG"]: root_logger.setLevel(logging.DEBUG) file_handler = logging.FileHandler("{}/{}".format(app.config["LOGDIR"], "rsvp.log")) file_handler.setFormatter(log_formatter) root_logger.addHandler(file_handler) console_handler = logging.StreamHandler() console_handler.setFormatter(log_formatter) root_logger.addHandler(console_handler) from extensions import db import models db.init_app(app) models.create_all(app) from views import views_bp app.register_blueprint(views_bp) return app
from bot import Bot from drawing import Artist import threading from models import create_all import turtle def start_bot(artist): bot = Bot(artist) bot.start() if __name__ == '__main__': create_all() artist = Artist(10) artist.draw_grid() # start bot on a separate thread bot_thread = threading.Thread(target=start_bot, args=(artist,), daemon=False) bot_thread.start() # drawing has to be done on the main thread turtle.done()
#!/usr/bin/env python # encoding: utf-8 import os, logging from smisk.mvc import main import controllers, models if __name__ == '__main__': models.setup_all() models.create_all() main( appdir=os.path.dirname(os.path.dirname(__file__)), log_level=logging.DEBUG )
# -*- coding: utf-8 -*- """Файл для инициализации/установки бота. Создаёт базу данных, создаёт файл config.ini из шаблона config_skeleton.ini. Посе запуска необходимо будет внести Token в config.ini PaVel 09.2016 """ import shutil, os if not os.path.exists(r'config.ini'): shutil.copy(r'config_skeleton.ini', r'config.ini') import models models.create_all()
def initialise_db(): print("Initialising database...", end="") sys.stdout.flush() init(config["connection_string"]) create_all() print("Done!")
def clean_up(): """Drop tables and create again to remove all test data.""" drop_all_tables() create_all()
def tearDown(self): """Cleans up after the test.""" drop_all_tables() create_all()
def create_db(app): create_all(app)
# -*- coding: utf-8 -*- from models import create_all, drop_all drop_all() create_all() if False: from application import db from models import List, Task, User user = User(name='test', hash='0ae383ef099312fa89a11ad8549e37663203ff9c', salt='a94a8fe5ccb19ba61c4c0873d391e987982fbbd3') # test: TODO customList1 = List(title='123cd0b0', rck='27783a2807f0def1e0f58cdfffb6199d5775319f', user=user) # test: Groceries customList2 = List(title='8bf5631bff73bb312f', rck='b87fc9682e38a6a6e1217eea718992533b586a3d', user=user) customList1Tasks = [ Task(list=customList1, priority=1, title='835f46f115a87309929c9efdbe70be', rck='0582086d3cdc0fe5a3e2f4ef017c541fc7c96cc7', state='open'), Task(list=customList1, priority=2, title='88a1bfe9f068bc185b07450dd86399', rck='3bd059ea8eab6ac40717fe3359820625599c27b4', state='open'), Task(list=customList1, priority=3, title='0468140554ab3d204af8f7b7c102d0',
def setUp(self): conn = hub.connect('sqlite:///:memory:') with hub.transaction() as tx: models.create_all(tx)
def __call__(self, parser, namespace, values, option_string=None): ctx.push() models.create_all() ctx.pop() parser.exit(0)
def create_and_update_db(): models.create_all(engine)