From 1195aef57e79caf440755ec8cedb54e44a53787c Mon Sep 17 00:00:00 2001 From: magowiz Date: Sat, 4 Dec 2021 14:40:34 +0100 Subject: [PATCH 01/17] installed aerich --- poetry.lock | 146 ++++++++++++++++++++++++++++++++++++++++++++++--- pyproject.toml | 1 + 2 files changed, 139 insertions(+), 8 deletions(-) diff --git a/poetry.lock b/poetry.lock index ea4daa2..6de002f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,3 +1,22 @@ +[[package]] +name = "aerich" +version = "0.5.8" +description = "A database migrations tool for Tortoise ORM." +category = "main" +optional = false +python-versions = ">=3.7,<4.0" + +[package.dependencies] +click = "*" +ddlparse = "*" +dictdiffer = "*" +pydantic = "*" +tortoise-orm = ">=0.17.7,<0.18.0" + +[package.extras] +aiomysql = ["aiomysql"] +asyncpg = ["asyncpg"] + [[package]] name = "aiosqlite" version = "0.16.1" @@ -83,7 +102,7 @@ python-versions = "*" [[package]] name = "charset-normalizer" -version = "2.0.8" +version = "2.0.9" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." category = "main" optional = false @@ -122,6 +141,31 @@ python-versions = ">=3.6" [package.extras] toml = ["tomli"] +[[package]] +name = "ddlparse" +version = "1.10.0" +description = "DDL parase and Convert to BigQuery JSON schema" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +pyparsing = "*" + +[[package]] +name = "dictdiffer" +version = "0.9.0" +description = "Dictdiffer is a library that helps you to diff and patch dictionaries." +category = "main" +optional = false +python-versions = "*" + +[package.extras] +all = ["Sphinx (>=3)", "sphinx-rtd-theme (>=0.2)", "check-manifest (>=0.42)", "mock (>=1.3.0)", "pytest-cov (>=2.10.1)", "pytest-isort (>=1.2.0)", "sphinx (>=3)", "tox (>=3.7.0)", "numpy (>=1.13.0)", "numpy (>=1.15.0)", "numpy (>=1.18.0)", "pytest (==5.4.3)", "pytest-pycodestyle (>=2)", "pytest-pydocstyle (>=2)", "pytest (>=6)", "pytest-pycodestyle (>=2.2.0)", "pytest-pydocstyle (>=2.2.0)", "numpy (>=1.20.0)"] +docs = ["Sphinx (>=3)", "sphinx-rtd-theme (>=0.2)"] +numpy = ["numpy (>=1.13.0)", "numpy (>=1.15.0)", "numpy (>=1.18.0)", "numpy (>=1.20.0)"] +tests = ["check-manifest (>=0.42)", "mock (>=1.3.0)", "pytest-cov (>=2.10.1)", "pytest-isort (>=1.2.0)", "sphinx (>=3)", "tox (>=3.7.0)", "pytest (==5.4.3)", "pytest-pycodestyle (>=2)", "pytest-pydocstyle (>=2)", "pytest (>=6)", "pytest-pycodestyle (>=2.2.0)", "pytest-pydocstyle (>=2.2.0)"] + [[package]] name = "dynaconf" version = "3.1.7" @@ -259,11 +303,26 @@ category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "pydantic" +version = "1.8.2" +description = "Data validation and settings management using python 3.6 type hinting" +category = "main" +optional = false +python-versions = ">=3.6.1" + +[package.dependencies] +typing-extensions = ">=3.7.4.3" + +[package.extras] +dotenv = ["python-dotenv (>=0.10.4)"] +email = ["email-validator (>=1.0.3)"] + [[package]] name = "pyparsing" version = "3.0.6" description = "Python parsing module" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -472,7 +531,7 @@ test = ["vcrpy (>=1.10.3)"] [[package]] name = "typing-extensions" -version = "4.0.0" +version = "4.0.1" description = "Backported and Experimental Type Hints for Python 3.6+" category = "main" optional = false @@ -494,9 +553,13 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "d9b142ea152ae9281bba5143f3b1cbf7c50d4ac19abec66ae383fa09bc47017e" +content-hash = "5896850e9ff67d9d336191d73dd738bbca16d857cf5a1a04f4bdac2f7dc350d8" [metadata.files] +aerich = [ + {file = "aerich-0.5.8-py3-none-any.whl", hash = "sha256:231ea9897f49e1a5e95884cd5fbed31df722dbd417a4778d301e9c46af7457a4"}, + {file = "aerich-0.5.8.tar.gz", hash = "sha256:1086d67788d805e273b828100fc66593ba96c1baeba7ff1198bf5be993975f4d"}, +] aiosqlite = [ {file = "aiosqlite-0.16.1-py3-none-any.whl", hash = "sha256:1df802815bb1e08a26c06d5ea9df589bcb8eec56e5f3378103b0f9b223c6703c"}, {file = "aiosqlite-0.16.1.tar.gz", hash = "sha256:2e915463164efa65b60fd1901aceca829b6090082f03082618afca6fb9c8fdf7"}, @@ -530,8 +593,8 @@ certifi = [ {file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"}, ] charset-normalizer = [ - {file = "charset-normalizer-2.0.8.tar.gz", hash = "sha256:735e240d9a8506778cd7a453d97e817e536bb1fc29f4f6961ce297b9c7a917b0"}, - {file = "charset_normalizer-2.0.8-py3-none-any.whl", hash = "sha256:83fcdeb225499d6344c8f7f34684c2981270beacc32ede2e669e94f7fa544405"}, + {file = "charset-normalizer-2.0.9.tar.gz", hash = "sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c"}, + {file = "charset_normalizer-2.0.9-py3-none-any.whl", hash = "sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721"}, ] click = [ {file = "click-8.0.3-py3-none-any.whl", hash = "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3"}, @@ -590,6 +653,14 @@ coverage = [ {file = "coverage-6.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:5829192582c0ec8ca4a2532407bc14c2f338d9878a10442f5d03804a95fac9de"}, {file = "coverage-6.2.tar.gz", hash = "sha256:e2cad8093172b7d1595b4ad66f24270808658e11acf43a8f95b41276162eb5b8"}, ] +ddlparse = [ + {file = "ddlparse-1.10.0-py3-none-any.whl", hash = "sha256:71761b3457c8720853af3aeef266e2da1b6edef50936969492d586d7046a2ac2"}, + {file = "ddlparse-1.10.0.tar.gz", hash = "sha256:6418681baa848eb01251ab79eb3d0ad7e140e6ab1deaae5a019353ddb3a908da"}, +] +dictdiffer = [ + {file = "dictdiffer-0.9.0-py2.py3-none-any.whl", hash = "sha256:442bfc693cfcadaf46674575d2eba1c53b42f5e404218ca2c2ff549f2df56595"}, + {file = "dictdiffer-0.9.0.tar.gz", hash = "sha256:17bacf5fbfe613ccf1b6d512bd766e6b21fb798822a133aa86098b8ac9997578"}, +] dynaconf = [ {file = "dynaconf-3.1.7-py2.py3-none-any.whl", hash = "sha256:f52fe5db7622da56a552275e8f64e4df46e3b4ae11158831b042e8ba2f6d1c96"}, {file = "dynaconf-3.1.7.tar.gz", hash = "sha256:e9d80b46ba4d9372f2f40c812594c963f74178140c0b596e57f2881001fc4d35"}, @@ -616,12 +687,28 @@ markdownify = [ {file = "markdownify-0.9.4.tar.gz", hash = "sha256:a32d7d6b0801f81d12a44533093a5681b402c6b7e9a7049512d26697517eb795"}, ] markupsafe = [ + {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-win32.whl", hash = "sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28"}, + {file = "MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f"}, + {file = "MarkupSafe-2.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win32.whl", hash = "sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d"}, {file = "MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567"}, @@ -630,14 +717,27 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9"}, + {file = "MarkupSafe-2.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415"}, {file = "MarkupSafe-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9"}, {file = "MarkupSafe-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75"}, {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194"}, + {file = "MarkupSafe-2.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win32.whl", hash = "sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64"}, {file = "MarkupSafe-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833"}, {file = "MarkupSafe-2.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26"}, @@ -647,6 +747,12 @@ markupsafe = [ {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902"}, {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e"}, + {file = "MarkupSafe-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win32.whl", hash = "sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74"}, {file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"}, {file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"}, @@ -667,6 +773,30 @@ py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] +pydantic = [ + {file = "pydantic-1.8.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:05ddfd37c1720c392f4e0d43c484217b7521558302e7069ce8d318438d297739"}, + {file = "pydantic-1.8.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:a7c6002203fe2c5a1b5cbb141bb85060cbff88c2d78eccbc72d97eb7022c43e4"}, + {file = "pydantic-1.8.2-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:589eb6cd6361e8ac341db97602eb7f354551482368a37f4fd086c0733548308e"}, + {file = "pydantic-1.8.2-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:10e5622224245941efc193ad1d159887872776df7a8fd592ed746aa25d071840"}, + {file = "pydantic-1.8.2-cp36-cp36m-win_amd64.whl", hash = "sha256:99a9fc39470010c45c161a1dc584997f1feb13f689ecf645f59bb4ba623e586b"}, + {file = "pydantic-1.8.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a83db7205f60c6a86f2c44a61791d993dff4b73135df1973ecd9eed5ea0bda20"}, + {file = "pydantic-1.8.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:41b542c0b3c42dc17da70554bc6f38cbc30d7066d2c2815a94499b5684582ecb"}, + {file = "pydantic-1.8.2-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:ea5cb40a3b23b3265f6325727ddfc45141b08ed665458be8c6285e7b85bd73a1"}, + {file = "pydantic-1.8.2-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:18b5ea242dd3e62dbf89b2b0ec9ba6c7b5abaf6af85b95a97b00279f65845a23"}, + {file = "pydantic-1.8.2-cp37-cp37m-win_amd64.whl", hash = "sha256:234a6c19f1c14e25e362cb05c68afb7f183eb931dd3cd4605eafff055ebbf287"}, + {file = "pydantic-1.8.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:021ea0e4133e8c824775a0cfe098677acf6fa5a3cbf9206a376eed3fc09302cd"}, + {file = "pydantic-1.8.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e710876437bc07bd414ff453ac8ec63d219e7690128d925c6e82889d674bb505"}, + {file = "pydantic-1.8.2-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:ac8eed4ca3bd3aadc58a13c2aa93cd8a884bcf21cb019f8cfecaae3b6ce3746e"}, + {file = "pydantic-1.8.2-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:4a03cbbe743e9c7247ceae6f0d8898f7a64bb65800a45cbdc52d65e370570820"}, + {file = "pydantic-1.8.2-cp38-cp38-win_amd64.whl", hash = "sha256:8621559dcf5afacf0069ed194278f35c255dc1a1385c28b32dd6c110fd6531b3"}, + {file = "pydantic-1.8.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8b223557f9510cf0bfd8b01316bf6dd281cf41826607eada99662f5e4963f316"}, + {file = "pydantic-1.8.2-cp39-cp39-manylinux1_i686.whl", hash = "sha256:244ad78eeb388a43b0c927e74d3af78008e944074b7d0f4f696ddd5b2af43c62"}, + {file = "pydantic-1.8.2-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:05ef5246a7ffd2ce12a619cbb29f3307b7c4509307b1b49f456657b43529dc6f"}, + {file = "pydantic-1.8.2-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:54cd5121383f4a461ff7644c7ca20c0419d58052db70d8791eacbbe31528916b"}, + {file = "pydantic-1.8.2-cp39-cp39-win_amd64.whl", hash = "sha256:4be75bebf676a5f0f87937c6ddb061fa39cbea067240d98e298508c1bda6f3f3"}, + {file = "pydantic-1.8.2-py3-none-any.whl", hash = "sha256:fec866a0b59f372b7e776f2d7308511784dace622e0992a0b59ea3ccee0ae833"}, + {file = "pydantic-1.8.2.tar.gz", hash = "sha256:26464e57ccaafe72b7ad156fdaa4e9b9ef051f69e175dbbb463283000c05ab7b"}, +] pyparsing = [ {file = "pyparsing-3.0.6-py3-none-any.whl", hash = "sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4"}, {file = "pyparsing-3.0.6.tar.gz", hash = "sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81"}, @@ -733,8 +863,8 @@ tweepy = [ {file = "tweepy-4.4.0.tar.gz", hash = "sha256:8d4b4520271b796fa7efc4c5d5ef3228af4d79f6a4d3ace3900b2778ed8f6f1c"}, ] typing-extensions = [ - {file = "typing_extensions-4.0.0-py3-none-any.whl", hash = "sha256:829704698b22e13ec9eaf959122315eabb370b0884400e9818334d8b677023d9"}, - {file = "typing_extensions-4.0.0.tar.gz", hash = "sha256:2cdf80e4e04866a9b3689a51869016d36db0814d84b8d8a568d22781d45d27ed"}, + {file = "typing_extensions-4.0.1-py3-none-any.whl", hash = "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"}, + {file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"}, ] urllib3 = [ {file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"}, diff --git a/pyproject.toml b/pyproject.toml index 5fd02ae..5e659fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ markdownify = "^0.9" appdirs = "^1.4" tweepy = "^4.1" facebook-sdk = {git = "https://github.com/mobolic/facebook-sdk.git"} +aerich = "^0.5.8" [tool.poetry.dev-dependencies] responses = "^0.13" From 1f27f2f78c76d522f0b98e5efbcf917a6b9bcc81 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sat, 4 Dec 2021 17:55:43 +0100 Subject: [PATCH 02/17] add aerich upgrade before init --- mobilizon_reshare/storage/db.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index 19e4b49..dcfb258 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -5,6 +5,8 @@ from tortoise import Tortoise from mobilizon_reshare.config.publishers import publisher_names from mobilizon_reshare.storage.query.write import update_publishers +from aerich import Command +from mobilizon_reshare.aerich_conf.database import TORTOISE_ORM logger = logging.getLogger(__name__) @@ -17,7 +19,16 @@ class MoReDB: if not self.is_init: self.path.parent.mkdir(parents=True, exist_ok=True) + async def __implement_db_changes__(self): + print('implementing db changes') + command = Command(tortoise_config=TORTOISE_ORM, app='models', + location='./') + await command.init() + await command.upgrade() + + async def setup(self): + await self.__implement_db_changes__() await Tortoise.init( db_url=f"sqlite:///{self.path}", modules={ From 653d98e0761b44087cb56aea83796d9d50917f23 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sat, 4 Dec 2021 17:56:31 +0100 Subject: [PATCH 03/17] add aerich configuration --- mobilizon_reshare/aerich_conf/__init__.py | 0 mobilizon_reshare/aerich_conf/database.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 mobilizon_reshare/aerich_conf/__init__.py create mode 100644 mobilizon_reshare/aerich_conf/database.py diff --git a/mobilizon_reshare/aerich_conf/__init__.py b/mobilizon_reshare/aerich_conf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mobilizon_reshare/aerich_conf/database.py b/mobilizon_reshare/aerich_conf/database.py new file mode 100644 index 0000000..5afa788 --- /dev/null +++ b/mobilizon_reshare/aerich_conf/database.py @@ -0,0 +1,23 @@ +"""tortoise orm conf for aerich""" +from pathlib import Path +from mobilizon_reshare.config.config import get_settings + +CONF_FILE = "settings.toml" + +SETTINGS = get_settings(CONF_FILE) +db_path = Path(SETTINGS.db_path) + +db_url = f"sqlite:///{db_path}" + +TORTOISE_ORM = { + "connections": {"default": db_url}, + "apps": { + "models": { + "models": ["mobilizon_reshare.models.event", + "mobilizon_reshare.models.notification", + "mobilizon_reshare.models.publication", + "mobilizon_reshare.models.publisher", "aerich.models"], + "default_connection": "default", + }, + }, +} From b04b0ba9235c1a21bf6fd42d3ceab4b8938f4dd2 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sat, 4 Dec 2021 18:24:09 +0100 Subject: [PATCH 04/17] add initial configuration, replace get_configuration with toml.load to avoid validation error on aerich init --- aerich.ini | 5 +++++ mobilizon_reshare/aerich_conf/database.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 aerich.ini diff --git a/aerich.ini b/aerich.ini new file mode 100644 index 0000000..56b62ce --- /dev/null +++ b/aerich.ini @@ -0,0 +1,5 @@ +[aerich] +tortoise_orm = mobilizon_reshare.aerich_conf.database.TORTOISE_ORM +location = ./migrations +src_folder = ./. + diff --git a/mobilizon_reshare/aerich_conf/database.py b/mobilizon_reshare/aerich_conf/database.py index 5afa788..dd6e295 100644 --- a/mobilizon_reshare/aerich_conf/database.py +++ b/mobilizon_reshare/aerich_conf/database.py @@ -1,11 +1,11 @@ """tortoise orm conf for aerich""" from pathlib import Path -from mobilizon_reshare.config.config import get_settings +import toml -CONF_FILE = "settings.toml" +CONF_FILE = "mobilizon_reshare/settings.toml" -SETTINGS = get_settings(CONF_FILE) -db_path = Path(SETTINGS.db_path) +SETTINGS = toml.load(CONF_FILE) +db_path = Path(SETTINGS['default']['db_path']) db_url = f"sqlite:///{db_path}" From f77e11fd9ed11697a7f3a701280936fa529413ac Mon Sep 17 00:00:00 2001 From: magowiz Date: Sat, 4 Dec 2021 19:34:00 +0100 Subject: [PATCH 05/17] add aenrich with migration initialized and auto-upgrade on start --- migrations/models/0_20211204192818_init.sql | 38 +++++++++++++++++++++ mobilizon_reshare/aerich_conf/database.py | 7 ++-- mobilizon_reshare/storage/db.py | 4 ++- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 migrations/models/0_20211204192818_init.sql diff --git a/migrations/models/0_20211204192818_init.sql b/migrations/models/0_20211204192818_init.sql new file mode 100644 index 0000000..1099eaf --- /dev/null +++ b/migrations/models/0_20211204192818_init.sql @@ -0,0 +1,38 @@ +-- upgrade -- +CREATE TABLE IF NOT EXISTS "event" ( + "id" CHAR(36) NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "description" TEXT, + "mobilizon_id" CHAR(36) NOT NULL, + "mobilizon_link" TEXT NOT NULL, + "thumbnail_link" TEXT, + "location" TEXT, + "begin_datetime" TIMESTAMP NOT NULL, + "end_datetime" TIMESTAMP NOT NULL +); +CREATE TABLE IF NOT EXISTS "publisher" ( + "id" CHAR(36) NOT NULL PRIMARY KEY, + "name" VARCHAR(256) NOT NULL, + "account_ref" TEXT +); +CREATE TABLE IF NOT EXISTS "publication" ( + "id" CHAR(36) NOT NULL PRIMARY KEY, + "status" SMALLINT NOT NULL /* FAILED: 0\nCOMPLETED: 1 */, + "timestamp" TIMESTAMP, + "reason" TEXT, + "event_id" CHAR(36) NOT NULL REFERENCES "event" ("id") ON DELETE CASCADE, + "publisher_id" CHAR(36) NOT NULL REFERENCES "publisher" ("id") ON DELETE CASCADE +); +CREATE TABLE IF NOT EXISTS "notification" ( + "id" CHAR(36) NOT NULL PRIMARY KEY, + "status" SMALLINT NOT NULL /* WAITING: 1\nFAILED: 2\nPARTIAL: 3\nCOMPLETED: 4 */, + "message" TEXT NOT NULL, + "publication_id" CHAR(36) REFERENCES "publication" ("id") ON DELETE CASCADE, + "target_id" CHAR(36) REFERENCES "publisher" ("id") ON DELETE CASCADE +); +CREATE TABLE IF NOT EXISTS "aerich" ( + "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + "version" VARCHAR(255) NOT NULL, + "app" VARCHAR(20) NOT NULL, + "content" JSON NOT NULL +); diff --git a/mobilizon_reshare/aerich_conf/database.py b/mobilizon_reshare/aerich_conf/database.py index dd6e295..3e5704b 100644 --- a/mobilizon_reshare/aerich_conf/database.py +++ b/mobilizon_reshare/aerich_conf/database.py @@ -1,11 +1,12 @@ """tortoise orm conf for aerich""" from pathlib import Path -import toml +from mobilizon_reshare.config.config import get_settings CONF_FILE = "mobilizon_reshare/settings.toml" -SETTINGS = toml.load(CONF_FILE) -db_path = Path(SETTINGS['default']['db_path']) +SETTINGS = get_settings(CONF_FILE) +db_path = Path(SETTINGS.db_path) +print(db_path) db_url = f"sqlite:///{db_path}" diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index dcfb258..e9f481f 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -20,9 +20,11 @@ class MoReDB: self.path.parent.mkdir(parents=True, exist_ok=True) async def __implement_db_changes__(self): + # return print('implementing db changes') command = Command(tortoise_config=TORTOISE_ORM, app='models', - location='./') + location='./migrations' + ) await command.init() await command.upgrade() From 6538abcb1b799a12f37bc20934268a80acd4ef75 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sat, 4 Dec 2021 20:26:16 +0100 Subject: [PATCH 06/17] re-init --- .../{0_20211204192818_init.sql => 4_20211204202300_None.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename migrations/models/{0_20211204192818_init.sql => 4_20211204202300_None.sql} (100%) diff --git a/migrations/models/0_20211204192818_init.sql b/migrations/models/4_20211204202300_None.sql similarity index 100% rename from migrations/models/0_20211204192818_init.sql rename to migrations/models/4_20211204202300_None.sql From 6cb1f3eedd8579821afd9b26e5ff4970e2dccf15 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sun, 5 Dec 2021 17:11:24 +0100 Subject: [PATCH 07/17] changed name of __implement_db_changes__ to _implement_db_changes and using logging facility for printing starting update database --- mobilizon_reshare/storage/db.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index e9f481f..e642589 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -19,18 +19,16 @@ class MoReDB: if not self.is_init: self.path.parent.mkdir(parents=True, exist_ok=True) - async def __implement_db_changes__(self): - # return - print('implementing db changes') + async def _implement_db_changes(self): + logging.info("Updating database to latest version") command = Command(tortoise_config=TORTOISE_ORM, app='models', - location='./migrations' - ) + location='./migrations') await command.init() await command.upgrade() async def setup(self): - await self.__implement_db_changes__() + await self._implement_db_changes() await Tortoise.init( db_url=f"sqlite:///{self.path}", modules={ From 9080f26e1cb5020501c6ecf5764e930b0c32c038 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sun, 5 Dec 2021 17:28:47 +0100 Subject: [PATCH 08/17] prova.txt --- prova.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prova.txt diff --git a/prova.txt b/prova.txt new file mode 100644 index 0000000..e69de29 From 14bd3afa5b8d8c60bac6f64c651bacfe1bdb8e6c Mon Sep 17 00:00:00 2001 From: magowiz Date: Sun, 5 Dec 2021 18:37:35 +0100 Subject: [PATCH 09/17] move aerich conf to storage.db --- aerich.ini | 3 +- mobilizon_reshare/aerich_conf/__init__.py | 0 mobilizon_reshare/aerich_conf/database.py | 24 ---------------- mobilizon_reshare/storage/db.py | 35 +++++++++++++++++++---- 4 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 mobilizon_reshare/aerich_conf/__init__.py delete mode 100644 mobilizon_reshare/aerich_conf/database.py diff --git a/aerich.ini b/aerich.ini index 56b62ce..e349d97 100644 --- a/aerich.ini +++ b/aerich.ini @@ -1,5 +1,4 @@ [aerich] -tortoise_orm = mobilizon_reshare.aerich_conf.database.TORTOISE_ORM +tortoise_orm = mobilizon_reshare.storage.db.TORTOISE_ORM location = ./migrations src_folder = ./. - diff --git a/mobilizon_reshare/aerich_conf/__init__.py b/mobilizon_reshare/aerich_conf/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/mobilizon_reshare/aerich_conf/database.py b/mobilizon_reshare/aerich_conf/database.py deleted file mode 100644 index 3e5704b..0000000 --- a/mobilizon_reshare/aerich_conf/database.py +++ /dev/null @@ -1,24 +0,0 @@ -"""tortoise orm conf for aerich""" -from pathlib import Path -from mobilizon_reshare.config.config import get_settings - -CONF_FILE = "mobilizon_reshare/settings.toml" - -SETTINGS = get_settings(CONF_FILE) -db_path = Path(SETTINGS.db_path) -print(db_path) - -db_url = f"sqlite:///{db_path}" - -TORTOISE_ORM = { - "connections": {"default": db_url}, - "apps": { - "models": { - "models": ["mobilizon_reshare.models.event", - "mobilizon_reshare.models.notification", - "mobilizon_reshare.models.publication", - "mobilizon_reshare.models.publisher", "aerich.models"], - "default_connection": "default", - }, - }, -} diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index e642589..9de7e7d 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -1,16 +1,41 @@ import logging from pathlib import Path - from tortoise import Tortoise - +from aerich import Command from mobilizon_reshare.config.publishers import publisher_names from mobilizon_reshare.storage.query.write import update_publishers -from aerich import Command -from mobilizon_reshare.aerich_conf.database import TORTOISE_ORM + +from mobilizon_reshare.config.config import get_settings logger = logging.getLogger(__name__) +def get_db_url(): + """gets db url from settings + + Returns: + str : db url + """ + settings = get_settings() + db_path = Path(settings.db_path) + db_url = f"sqlite:///{db_path}" + return db_url + + +TORTOISE_ORM = { + "connections": {"default": get_db_url()}, + "apps": { + "models": { + "models": ["mobilizon_reshare.models.event", + "mobilizon_reshare.models.notification", + "mobilizon_reshare.models.publication", + "mobilizon_reshare.models.publisher", "aerich.models"], + "default_connection": "default", + }, + }, +} + + class MoReDB: def __init__(self, path: Path): self.path = path @@ -30,7 +55,7 @@ class MoReDB: async def setup(self): await self._implement_db_changes() await Tortoise.init( - db_url=f"sqlite:///{self.path}", + db_url=get_db_url(), modules={ "models": [ "mobilizon_reshare.models.event", From fa431c377573fe632134c1932117a4e50e4033b6 Mon Sep 17 00:00:00 2001 From: magowiz Date: Sun, 5 Dec 2021 18:43:28 +0100 Subject: [PATCH 10/17] remove test file --- prova.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 prova.txt diff --git a/prova.txt b/prova.txt deleted file mode 100644 index e69de29..0000000 From 681baed1d632bdbeecf5b7c9adb3f016715ca6df Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 7 Dec 2021 11:34:21 +0100 Subject: [PATCH 11/17] change first script name --- .../{4_20211204202300_None.sql => 0_20211207110159_init.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename migrations/models/{4_20211204202300_None.sql => 0_20211207110159_init.sql} (100%) diff --git a/migrations/models/4_20211204202300_None.sql b/migrations/models/0_20211207110159_init.sql similarity index 100% rename from migrations/models/4_20211204202300_None.sql rename to migrations/models/0_20211207110159_init.sql From e6f25178a5625ad7bcc2b49d8be416c9395c5b72 Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 7 Dec 2021 12:10:32 +0100 Subject: [PATCH 12/17] handle aerich migrations not found --- mobilizon_reshare/storage/db.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index 9de7e7d..b5ce121 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -1,4 +1,5 @@ import logging +import sys from pathlib import Path from tortoise import Tortoise from aerich import Command @@ -46,10 +47,16 @@ class MoReDB: async def _implement_db_changes(self): logging.info("Updating database to latest version") - command = Command(tortoise_config=TORTOISE_ORM, app='models', - location='./migrations') - await command.init() - await command.upgrade() + try: + + command = Command(tortoise_config=TORTOISE_ORM, app='models', + location='./migrations') + await command.init() + await command.upgrade() + except FileNotFoundError: + logging.critical("aerich configuration not found, fatal error") + # raise + sys.exit(1) async def setup(self): From 42ffc2522113d353dc5cbd75919f73c634762ecf Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 7 Dec 2021 12:10:44 +0100 Subject: [PATCH 13/17] ignore test_run.sh --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e5043ef..47bf74d 100644 --- a/.gitignore +++ b/.gitignore @@ -181,3 +181,6 @@ etc/ var/ docker-image.tar.gz .guix-root + +# test run script +test_run.sh From f8ace3feadd172ef02d7acfbfe8ef2291740baa0 Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 7 Dec 2021 16:54:17 +0100 Subject: [PATCH 14/17] ignore pylintrc --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 47bf74d..c7c969e 100644 --- a/.gitignore +++ b/.gitignore @@ -184,3 +184,6 @@ docker-image.tar.gz # test run script test_run.sh + +# pylint rc +pylintrc From c27a18cc174bc50ff195aceb208c47da08daf1a0 Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 7 Dec 2021 16:58:12 +0100 Subject: [PATCH 15/17] completed chain, handling exception --- mobilizon_reshare/cli/__init__.py | 19 ++++++++++++++-- mobilizon_reshare/storage/db.py | 38 +++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/mobilizon_reshare/cli/__init__.py b/mobilizon_reshare/cli/__init__.py index 2b6bc02..dc17e76 100644 --- a/mobilizon_reshare/cli/__init__.py +++ b/mobilizon_reshare/cli/__init__.py @@ -3,6 +3,7 @@ import logging import traceback from logging.config import dictConfig from pathlib import Path +import sys from mobilizon_reshare.config.config import get_settings from mobilizon_reshare.storage.db import tear_down, MoReDB @@ -20,11 +21,25 @@ async def init(settings_file): dictConfig(settings["logging"]) db_path = Path(settings.db_path) db = MoReDB(db_path) - await db.setup() + db_setup = asyncio.create_task(db.setup()) + _, _ = await asyncio.wait({db_setup}, + return_when=asyncio.FIRST_EXCEPTION) + if db_setup.exception(): + logging.critical("exception during db setup") + raise db_setup.exception() async def _safe_execution(f, settings_file): - await init(settings_file) + init_task = asyncio.create_task(init(settings_file)) + _, _ = await asyncio.wait({init_task}, + return_when=asyncio.FIRST_EXCEPTION) + if init_task.exception(): + logging.critical("exception during init") + # raise init_task.exception() + # sys.exit(1) + loop = asyncio.get_event_loop() + loop.stop() + return_code = 1 try: return_code = await f() diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index b5ce121..6c048df 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -1,5 +1,5 @@ import logging -import sys +import asyncio from pathlib import Path from tortoise import Tortoise from aerich import Command @@ -37,8 +37,33 @@ TORTOISE_ORM = { } +async def shutdown(loop): + """shutdown method""" + logging.critical("SHUTDOWN CALLED") + logging.info("closing database connections") + tasks = [t for t in asyncio.all_tasks() if t is asyncio.current_task()] + _ = [task.cancel() for task in tasks] + logging.info("Cancelling %i tasks", len(tasks)) + await asyncio.gather(*tasks, return_exceptions=True) + logging.info("flushing metrics") + loop.stop() + + +async def handle_exception(loop, context): + """exception handler""" + logging.critical("HANDLER CALLED") + msg = context.get("exception", context["message"]) + logging.critical("Caught exception: %s", msg) + logging.info("shutting down") + await shutdown(loop) + await tear_down() + + class MoReDB: def __init__(self, path: Path): + loop = asyncio.get_event_loop() + loop.set_exception_handler(handle_exception) + self.path = path # TODO: Check if DB is openable/"queriable" self.is_init = self.path.exists() and (not self.path.is_dir()) @@ -55,12 +80,15 @@ class MoReDB: await command.upgrade() except FileNotFoundError: logging.critical("aerich configuration not found, fatal error") - # raise - sys.exit(1) - + raise async def setup(self): - await self._implement_db_changes() + implement_db_changes = asyncio.create_task(self._implement_db_changes()) + _, _ = await asyncio.wait({implement_db_changes}, + return_when=asyncio.FIRST_EXCEPTION) + if implement_db_changes.exception(): + logging.critical("exception during aerich init") + raise implement_db_changes.exception() await Tortoise.init( db_url=get_db_url(), modules={ From e836e51ee463fb193cf8d10e313d51a65a8c03a3 Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 14 Dec 2021 22:37:49 +0100 Subject: [PATCH 16/17] fixed exit on migration exception --- mobilizon_reshare/storage/db.py | 70 +++++++++++---------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/mobilizon_reshare/storage/db.py b/mobilizon_reshare/storage/db.py index 6c048df..5d13d8e 100644 --- a/mobilizon_reshare/storage/db.py +++ b/mobilizon_reshare/storage/db.py @@ -1,5 +1,5 @@ import logging -import asyncio +import sys from pathlib import Path from tortoise import Tortoise from aerich import Command @@ -23,47 +23,26 @@ def get_db_url(): return db_url -TORTOISE_ORM = { - "connections": {"default": get_db_url()}, - "apps": { - "models": { - "models": ["mobilizon_reshare.models.event", - "mobilizon_reshare.models.notification", - "mobilizon_reshare.models.publication", - "mobilizon_reshare.models.publisher", "aerich.models"], - "default_connection": "default", +def get_tortoise_orm(): + return { + "connections": {"default": get_db_url()}, + "apps": { + "models": { + "models": [ + "mobilizon_reshare.models.event", + "mobilizon_reshare.models.notification", + "mobilizon_reshare.models.publication", + "mobilizon_reshare.models.publisher", + "aerich.models", + ], + "default_connection": "default", + }, }, - }, -} - - -async def shutdown(loop): - """shutdown method""" - logging.critical("SHUTDOWN CALLED") - logging.info("closing database connections") - tasks = [t for t in asyncio.all_tasks() if t is asyncio.current_task()] - _ = [task.cancel() for task in tasks] - logging.info("Cancelling %i tasks", len(tasks)) - await asyncio.gather(*tasks, return_exceptions=True) - logging.info("flushing metrics") - loop.stop() - - -async def handle_exception(loop, context): - """exception handler""" - logging.critical("HANDLER CALLED") - msg = context.get("exception", context["message"]) - logging.critical("Caught exception: %s", msg) - logging.info("shutting down") - await shutdown(loop) - await tear_down() + } class MoReDB: def __init__(self, path: Path): - loop = asyncio.get_event_loop() - loop.set_exception_handler(handle_exception) - self.path = path # TODO: Check if DB is openable/"queriable" self.is_init = self.path.exists() and (not self.path.is_dir()) @@ -74,21 +53,20 @@ class MoReDB: logging.info("Updating database to latest version") try: - command = Command(tortoise_config=TORTOISE_ORM, app='models', - location='./migrations') + command = Command( + tortoise_config=get_tortoise_orm(), + app="models", + location="./migrations", + ) await command.init() await command.upgrade() except FileNotFoundError: logging.critical("aerich configuration not found, fatal error") - raise + await tear_down() + sys.exit(1) async def setup(self): - implement_db_changes = asyncio.create_task(self._implement_db_changes()) - _, _ = await asyncio.wait({implement_db_changes}, - return_when=asyncio.FIRST_EXCEPTION) - if implement_db_changes.exception(): - logging.critical("exception during aerich init") - raise implement_db_changes.exception() + await self._implement_db_changes() await Tortoise.init( db_url=get_db_url(), modules={ From 6d84c266146576f3d871987072368cbfacc76c3f Mon Sep 17 00:00:00 2001 From: magowiz Date: Tue, 14 Dec 2021 22:47:51 +0100 Subject: [PATCH 17/17] Revert "ignore pylintrc" This reverts commit f8ace3feadd172ef02d7acfbfe8ef2291740baa0. --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index c7c969e..47bf74d 100644 --- a/.gitignore +++ b/.gitignore @@ -184,6 +184,3 @@ docker-image.tar.gz # test run script test_run.sh - -# pylint rc -pylintrc