From 6ba10b0e024263b7a79766093d87e0cc8230ac76 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Mon, 16 Jan 2023 13:48:01 -0500 Subject: [PATCH 1/2] Removed .env --- .env | 16 ---------------- persistence/models/city.py | 7 +++++-- 2 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 82c1fada..00000000 --- a/.env +++ /dev/null @@ -1,16 +0,0 @@ -# production database credentials -PROD_DB_USER=postgres -PROD_DB_PASSWORD= -PROD_DB_HOST=localhost -PROD_DB_PORT=5432 - -# test database credentials -TEST_DB_USER=postgres -TEST_DB_PASSWORD=postgres -TEST_DB_HOST=localhost -TEST_DB_PORT=5432 - -#Gitlab token -HUB_TOKEN=9s_CJYh5TcWhyYL416MM - -DEV_SECRET_NAME=dp.st.dev.Axvak1ILOlCOwUNGajv7fg5VPaacFR6OL1kdb3YGWHX \ No newline at end of file diff --git a/persistence/models/city.py b/persistence/models/city.py index bc95fa21..2b9e9a12 100644 --- a/persistence/models/city.py +++ b/persistence/models/city.py @@ -11,6 +11,7 @@ from persistence.db_config import Base from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.orm import relationship import datetime +import numpy as np class City(Base): @@ -41,7 +42,9 @@ class City(Base): self.name = name self.srs_name = srs_name self.country_code = country_code - self.lower_corner = l_corner.tolist() - self.upper_corner = u_corner.tolist() + l_corner = l_corner.tolist() if type(l_corner) == np.ndarray else l_corner + u_corner = u_corner.tolist() if type(u_corner) == np.ndarray else u_corner + self.lower_corner = l_corner + self.upper_corner = u_corner From 708075fd3c75765d5b493637745199ab074602e8 Mon Sep 17 00:00:00 2001 From: Peter Yefi Date: Mon, 16 Jan 2023 14:11:08 -0500 Subject: [PATCH 2/2] create log file automatically if it doesn't exist --- hub_logger/__init__.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hub_logger/__init__.py b/hub_logger/__init__.py index e440afbf..e4d66f89 100644 --- a/hub_logger/__init__.py +++ b/hub_logger/__init__.py @@ -1,6 +1,15 @@ import logging as logger from pathlib import Path +import os -log_file = (Path(__file__).parent.parent / 'logs/hub.log').resolve() -logger.basicConfig(filename=log_file, format="%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} " - "- %(message)s", level=logger.DEBUG) +log_dir = (Path(__file__).parent.parent / 'logs').resolve() +log_file = (log_dir / 'hub.log').resolve() +try: + if not os.path.isfile(log_file): + os.mkdir(log_dir) + with open(log_file, 'x'): + pass + logger.basicConfig(filename=log_file, format="%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} " + "- %(message)s", level=logger.DEBUG) +except IOError as err: + print(f'I/O exception: {err}')