Skip to content

Commit 87121f3

Browse files
committed
Initial commit.
0 parents  commit 87121f3

12 files changed

+891
-0
lines changed

.gitignore

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/not to
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
# misc
107+
.DS_Store
108+
docs
109+
110+
# Credentials
111+
creds/
112+
creds/*
113+
gcloud.json
114+
ca-certificate.crt
115+
116+
# Idea
117+
.idea/
118+
119+
# logs
120+
logs/*
121+
nohup.out
122+
123+

Makefile

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
SRCPATH := $(shell pwd)
2+
PROJECTNAME := $(shell basename $(CURDIR))
3+
ENTRYPOINT := $(PROJECTNAME).ini
4+
5+
define HELP
6+
Manage $(PROJECTNAME). Usage:
7+
8+
make run - Run $(PROJECTNAME).
9+
make deploy - Pull latest build and deploy to production.
10+
make update - Update pip dependencies via Python Poetry.
11+
make format - Format code with Python's `Black` library.
12+
make lint - Check code formatting with flake8
13+
make clean - Remove cached files and lock files.
14+
endef
15+
export HELP
16+
17+
18+
.PHONY: run restart deploy update format lint clean help
19+
20+
requirements: .requirements.txt
21+
env: .venv/bin/activate
22+
23+
24+
.requirements.txt: requirements.txt
25+
$(shell . .venv/bin/activate && pip install -r requirements.txt)
26+
27+
28+
all help:
29+
@echo "$$HELP"
30+
31+
32+
.PHONY: run
33+
run: env
34+
service $(PROJECTNAME) start
35+
36+
37+
.PHONY: deploy
38+
deploy:
39+
make clean
40+
$(shell . ./deploy.sh)
41+
42+
43+
.PHONY: update
44+
update: env
45+
poetry update
46+
poetry export -f requirements.txt --output requirements.txt --without-hashes
47+
48+
49+
.PHONY: format
50+
format: env
51+
$(shell . .venv/bin/activate && isort ./)
52+
$(shell . .venv/bin/activate && black ./)
53+
54+
55+
.PHONY: lint
56+
lint:
57+
flake8 ./app --count --select=E9,F63,F7,F82 --show-source --statistics
58+
59+
60+
.PHONY: clean
61+
clean:
62+
find . -name '*.pyc' -delete
63+
find . -name '__pycache__' -delete
64+
find . -name 'poetry.lock' -delete
65+
find . -name 'Pipefile.lock' -delete
66+
find . -name 'logs/*' -delete
67+
find . -name '.pytest_cache' -delete

config.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Database config."""
2+
from datetime import datetime
3+
from os import environ, path
4+
5+
from dotenv import load_dotenv
6+
7+
# Load variables from .env
8+
basedir = path.abspath(path.dirname(__file__))
9+
load_dotenv(path.join(basedir, ".env"))
10+
11+
12+
SQLALCHEMY_DATABASE_URI = environ.get("SQLALCHEMY_DATABASE_URI")
13+
TIME_NOW = datetime.now()

deploy.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
if [ -d ".venv" ]
4+
then
5+
. .venv/bin/activate
6+
pip install -r requirements.txt
7+
else
8+
python3 -m venv .venv
9+
. .venv/bin/activate
10+
python3 -m pip install --upgrade pip
11+
pip install -r requirements.txt
12+
fi

main.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from sqlalchemy_tutorial import init_script
2+
3+
if __name__ == "__main__":
4+
init_script()

mypy.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[mypy]
2+
python_version = 3.8
3+
warn_return_any = True
4+
warn_unused_configs = True

0 commit comments

Comments
 (0)