From 1647b4cf20f422e7137027fe6fc2cbd7fe119554 Mon Sep 17 00:00:00 2001 From: Snakes <104547575+TLSM@users.noreply.github.com> Date: Wed, 29 Mar 2023 22:59:34 -0400 Subject: [PATCH] Update dotenv support to make operative (#564) b46ada9f72 added support for dotenv files to be loaded in lieu of actual environment variables. This code has since been neglected across infrastructure changes that removed the need for an env file, moved its location, and changed dependency management style. This won't be operative in production (and already isn't, since there'd be an ImportError on 'dotenv' if so) but makes some local testing setups more convenient. --- .gitignore | 12 +++++++++--- files/__main__.py | 3 ++- poetry.lock | 17 ++++++++++++++++- pyproject.toml | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5b41b0b2d..b1f355448 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -image.* -video.mp4 -video.webm +# Python, Flask, IDEs cache/ __pycache__/ .idea/ @@ -12,3 +10,11 @@ flask_session/ .DS_Store .venv *.pyc + +# rdrama Media Runtime Artifacts +image.* +video.mp4 +video.webm + +# Optional env file for some environments +env diff --git a/files/__main__.py b/files/__main__.py index 7828f30ec..f0e1a3be2 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -50,7 +50,8 @@ if bool_from_string(environ.get("ENFORCE_PRODUCTION", True)) and app.debug: if environ.get("SITE_ID") is None: from dotenv import load_dotenv - load_dotenv(dotenv_path=Path("env")) + load_dotenv(dotenv_path=Path("bootstrap/site_env")) + load_dotenv(dotenv_path=Path("env"), override=True) # ...and let's add the flask profiler if it's enabled... diff --git a/poetry.lock b/poetry.lock index f693f5ee9..b6de3c2d7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -718,6 +718,17 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" [package.dependencies] six = ">=1.5" +[[package]] +name = "python-dotenv" +version = "1.0.0" +description = "Read key-value pairs from a .env file and set them as environment variables" +category = "main" +optional = false +python-versions = ">=3.8" + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "python-engineio" version = "4.3.4" @@ -1065,7 +1076,7 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "1.1" python-versions = "~3.10" # updating to 3.11 causes instability; see https://github.com/themotte/rDrama/issues/446 -content-hash = "bb33c14d0075dd9f0d81589e0445495444bfe16c73bd9cd9f88e3d17e60cab0e" +content-hash = "0607803380bd7078b955572621d5f794e7eeb3fa08a5794c17fac0e14e980431" [metadata.files] alembic = [ @@ -1997,6 +2008,10 @@ python-dateutil = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, ] +python-dotenv = [ + {file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"}, + {file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"}, +] python-engineio = [ {file = "python-engineio-4.3.4.tar.gz", hash = "sha256:d8d8b072799c36cadcdcc2b40d2a560ce09797ab3d2d596b2ad519a5e4df19ae"}, {file = "python_engineio-4.3.4-py3-none-any.whl", hash = "sha256:7454314a529bba20e745928601ffeaf101c1b5aca9a6c4e48ad397803d10ea0c"}, diff --git a/pyproject.toml b/pyproject.toml index 21c87d01f..f00c8a269 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ matplotlib = "*" Pillow = "*" psutil = "*" pyotp = "*" +python-dotenv = "*" qrcode = "*" redis = "*" requests = "*"