From 15521e73fb84fb4282a484ff0c9bb88ed1d144ae Mon Sep 17 00:00:00 2001 From: zevaryx Date: Sat, 26 Mar 2022 11:57:05 -0600 Subject: [PATCH] Add timezone data to connections --- jarvis_core/db/__init__.py | 5 ++++- poetry.lock | 14 +++++++++++++- pyproject.toml | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/jarvis_core/db/__init__.py b/jarvis_core/db/__init__.py index 9f4e4ae..5a1e219 100644 --- a/jarvis_core/db/__init__.py +++ b/jarvis_core/db/__init__.py @@ -1,6 +1,7 @@ """JARVIS database models and utilities.""" from bson import ObjectId from motor.motor_asyncio import AsyncIOMotorClient +from pytz import utc from umongo.frameworks import MotorAsyncIOInstance from jarvis_core.util import find @@ -25,7 +26,9 @@ def connect( port: Port """ global CLIENT, JARVISDB, CTC2DB, JARVIS_INST, CTC2_INST - CLIENT = AsyncIOMotorClient(host=host, username=username, password=password, port=port) + CLIENT = AsyncIOMotorClient( + host=host, username=username, password=password, port=port, tz_aware=True, tzinfo=utc + ) JARVISDB = CLIENT.narvis if testing else CLIENT.jarvis CTC2DB = CLIENT.ctc2 diff --git a/poetry.lock b/poetry.lock index 68aa885..a613b94 100644 --- a/poetry.lock +++ b/poetry.lock @@ -442,6 +442,14 @@ rope = ["rope (>0.10.5)"] test = ["pylint (>=2.5.0)", "pytest", "pytest-cov", "coverage", "numpy", "pandas", "matplotlib", "pyqt5", "flaky"] yapf = ["yapf"] +[[package]] +name = "pytz" +version = "2022.1" +description = "World timezone definitions, modern and historical" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "pyyaml" version = "6.0" @@ -565,7 +573,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "8edf07b473e9615a836f71510d792021c6760ef94abe4b720f9ff12a37c5dce5" +content-hash = "8f9ec3d441f140e2a21a45d17e61fbd0a785da3b5845cc8fe25b017cdad6c6dd" [metadata.files] aiohttp = [ @@ -1050,6 +1058,10 @@ python-lsp-server = [ {file = "python-lsp-server-1.3.3.tar.gz", hash = "sha256:1b48ccd8b70103522e8a8b9cb9ae1be2b27a5db0dfd661e7e44e6253ebefdc40"}, {file = "python_lsp_server-1.3.3-py3-none-any.whl", hash = "sha256:ea7b1e623591ccbfbbf8e5dfe0df8119f27863125a58bdcacbacd1937d8e8cb3"}, ] +pytz = [ + {file = "pytz-2022.1-py2.py3-none-any.whl", hash = "sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"}, + {file = "pytz-2022.1.tar.gz", hash = "sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7"}, +] pyyaml = [ {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, diff --git a/pyproject.toml b/pyproject.toml index 8c993cc..7006200 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ orjson = "^3.6.6" motor = "^2.5.1" umongo = "^3.1.0" PyYAML = "^6.0" +pytz = "^2022.1" [tool.poetry.dev-dependencies] pytest = "^5.2"