Adding logging, new cookiecutter params for cors and static report, changed factory function
parent
ae2f1c696c
commit
7458224fa1
@ -0,0 +1,2 @@
|
|||||||
|
[alembic]
|
||||||
|
script_location = migrations
|
@ -1,28 +0,0 @@
|
|||||||
#
|
|
||||||
# This file is autogenerated by pip-compile
|
|
||||||
# To update, run:
|
|
||||||
#
|
|
||||||
# pip-compile --output-file dev_requirements.txt dev_requirements.in
|
|
||||||
#
|
|
||||||
--trusted-host pypi.python.org
|
|
||||||
|
|
||||||
appdirs==1.4.3 # via black
|
|
||||||
atomicwrites==1.2.1 # via pytest
|
|
||||||
attrs==18.2.0 # via black, pytest
|
|
||||||
black==18.9b0
|
|
||||||
bumpversion==0.5.3
|
|
||||||
click==7.0 # via black, pip-tools
|
|
||||||
coverage==4.5.2 # via pytest-cov
|
|
||||||
flake8==3.6.0
|
|
||||||
mccabe==0.6.1 # via flake8
|
|
||||||
more-itertools==4.3.0 # via pytest
|
|
||||||
pip-tools==3.1.0
|
|
||||||
pluggy==0.8.0 # via pytest
|
|
||||||
py==1.7.0 # via pytest
|
|
||||||
pycodestyle==2.4.0 # via flake8
|
|
||||||
pyflakes==2.0.0 # via flake8
|
|
||||||
pytest-cov==2.6.0
|
|
||||||
pytest==4.0.1
|
|
||||||
six==1.11.0 # via more-itertools, pip-tools, pytest
|
|
||||||
toml==0.10.0 # via black
|
|
||||||
werkzeug==0.14.1
|
|
@ -1,15 +0,0 @@
|
|||||||
#
|
|
||||||
# This file is autogenerated by pip-compile
|
|
||||||
# To update, run:
|
|
||||||
#
|
|
||||||
# pip-compile --output-file requirements.txt requirements.in
|
|
||||||
#
|
|
||||||
--trusted-host pypi.python.org
|
|
||||||
|
|
||||||
click==7.0
|
|
||||||
molten==0.7.3
|
|
||||||
mypy-extensions==0.4.1 # via typing-inspect
|
|
||||||
psycopg2-binary==2.7.6.1
|
|
||||||
sqlalchemy==1.2.14
|
|
||||||
typing-extensions==3.6.6 # via molten
|
|
||||||
typing-inspect==0.3.1 # via molten
|
|
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# setting -e to exit immediately on a command failure.
|
||||||
|
# setting -o pipefail sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
if [ -z "$VIRTUAL_ENV" ]; then
|
||||||
|
echo "warning: you are not in a virtualenv"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pip install -U pip pip-tools
|
||||||
|
pip-compile requirements.in
|
||||||
|
pip-compile dev_requirements.in
|
||||||
|
pip-sync requirements.txt dev_requirements.txt
|
@ -0,0 +1,29 @@
|
|||||||
|
import logging.config
|
||||||
|
import sys
|
||||||
|
|
||||||
|
FORMAT = "[%(asctime)s] [PID %(process)d] [%(threadName)s] [%(request_id)s] [%(name)s] [%(levelname)s] %(message)s" # noqa
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logging():
|
||||||
|
logging.config.dictConfig(
|
||||||
|
{
|
||||||
|
"disable_existing_loggers": False,
|
||||||
|
"version": 1,
|
||||||
|
"filters": {
|
||||||
|
"request_id": {"()": "molten.contrib.request_id.RequestIdFilter"}
|
||||||
|
},
|
||||||
|
"formatters": {"console": {"format": FORMAT}},
|
||||||
|
"handlers": {
|
||||||
|
"default": {
|
||||||
|
"level": "DEBUG",
|
||||||
|
"class": "logging.StreamHandler",
|
||||||
|
"stream": sys.stderr,
|
||||||
|
"formatter": "console",
|
||||||
|
"filters": ["request_id"],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loggers": {
|
||||||
|
"": {"handlers": ["default"], "level": "DEBUG", "propagate": False}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
@ -0,0 +1,21 @@
|
|||||||
|
"""isort:skip_file
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys; sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")) # noqa
|
||||||
|
|
||||||
|
from alembic import context
|
||||||
|
from {{cookiecutter.package_name}}.index import create_app
|
||||||
|
from {{cookiecutter.package_name}}.db import Base
|
||||||
|
from molten.contrib.sqlalchemy import EngineData
|
||||||
|
|
||||||
|
_, app = create_app()
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_online(engine_data: EngineData):
|
||||||
|
with engine_data.engine.connect() as connection:
|
||||||
|
context.configure(connection=connection, target_metadata=Base.metadata)
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
app.injector.get_resolver().resolve(run_migrations_online)()
|
Loading…
Reference in New Issue