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}') 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